在我的代码中,我需要在循环内部进行迭代,并且对于循环中的每次迭代,我都必须填写某些单元格中值不同的数据。
阅读 sap 文档后,我得出的结论是,我需要使用读取表将每次迭代填充到稍后我将处理的工作区域中。
我已经声明了以下表格:
it_sap包含来自 VBRK 和 VBRP 表的连接内容
wa_sap作为工作区
it_ext包含来自外部数据库的另一个连接的内容
wa_ext作为工作区。
这就是我的循环实际上的样子:
LOOP AT it_sap INTO wa_sap.
wa_sap-tipo_documento = wa_sap-xblnr+2(1). " Linea
tiket = wa_sap-xblnr+9(7).
creationyear = wa_sap-fkdat+0(4).
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = tiket
IMPORTING
output = tiket.
CONCATENATE creationyear '/' wa_sap-vkorg wa_sap-xblnr+7(2) '/' tiket INTO wa_sap-codalb.
"CLEAR position.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = wa_sap-posnr
IMPORTING
output = position.
READ TABLE it_ext INTO wa_ext
WITH KEY codalb = wa_ext-codalb
tipo_documento = wa_ext-tipo_documento.
IF sy-subrc = 0.
wa_sap-import_total = wa_ext-import_total.
wa_sap-import = wa_ext-import.
wa_sap-price = wa_ext-price.
wa_sap-price_total = wa_ext-price_total.
wa_sap-disccount = wa_ext-disccount.
wa_sap-quantity = wa_ext-quantity.
MODIFY it_sap FROM wa_sap.
IF wa_sap-importe_total <> wa_sap-netwr. "AND position = 1 .
APPEND wa_sap TO it_results.
ENDIF.
ENDIF.
ENDLOOP.
它是如何工作的?我知道通过使用条件,sy-subrc = 0
我可以查看前面的语句是 true 还是 false,但我不太明白使用 steament 是如何READ
工作SELECT
的。
感谢你们!