Bucles en sap
Enviado por ANDRES FELIPE ORTIZ CORONADO • 30 de Mayo de 2019 • Trabajo • 2.046 Palabras (9 Páginas) • 170 Visitas
FORM bdc.
DATA: lt_lfbw TYPE TABLE OF lfbw,
ls_lfbw LIKE LINE OF lt_lfbw.
DATA: l_cont TYPE i,
ln2(2) TYPE n,
l_marc TYPE char01,
l_mod TYPE i,
aux_gs_file TYPE ty_file,
lv_tabix TYPE sy-tabix.
CLEAR: l_cont.
* READ TABLE gt_file INTO gs_file INDEX '1'.
LOOP AT gt_file INTO gs_file.
lv_tabix = sy-tabix.
PERFORM fill_screen USING:
'X' 'SAPMF05A' '0100',
space 'BDC_OKCODE' '/00',
space 'BKPF-BLDAT' gs_file-bldat,
space 'BKPF-BLART' gs_file-blart,
space 'BKPF-BUKRS' gs_file-bukrs,
space 'BKPF-BUDAT' gs_file-bldat,
space 'BKPF-MONAT' gs_file-bldat+2(2),
space 'BKPF-WAERS' gs_file-waers.
IF gs_file-waers = 'USD'.
PERFORM fill_screen USING:
space 'BKPF-KURSF' gs_file-kursf.
ENDIF.
PERFORM fill_screen USING:
space 'BKPF-XBLNR' gs_file-xblnr,
space 'RF05A-NEWBS' gs_file-bschl1,
space 'RF05A-NEWKO' gs_file-hkont.
CLEAR : l_marc, l_cont.
LOOP AT gt_file INTO aux_gs_file WHERE xblnr = gs_file-xblnr.
l_cont = l_cont + 1.
PERFORM fill_screen USING:
'X' 'SAPMF05A' '0300',
space 'BDC_OKCODE' '/00',
space 'BSEG-WRBTR' aux_gs_file-wrbtr,
space 'BSEG-ZUONR' aux_gs_file-zuonr,
space 'BSEG-MWSKZ' aux_gs_file-mwskz.
IF l_marc IS INITIAL.
PERFORM fill_screen USING:
space 'BKPF-XMWST' 'X'.
l_marc = 'X'.
ENDIF.
PERFORM fill_screen USING:
space 'BSEG-SGTXT' aux_gs_file-sgtxt,
space 'RF05A-NEWBS' aux_gs_file-bschl,
space 'RF05A-NEWKO' aux_gs_file-lifnr,
'X' 'SAPLKACB' '0002',
space 'BDC_OKCODE' 'ENTE'.
IF NOT gs_file-prctr IS INITIAL.
PERFORM fill_screen USING:
space 'COBL-PRCTR' aux_gs_file-prctr.
ENDIF.
IF NOT gs_file-kostl IS INITIAL.
PERFORM fill_screen USING:
space 'COBL-KOSTL' aux_gs_file-kostl.
ENDIF.
IF NOT gs_file-aufnr IS INITIAL.
PERFORM fill_screen USING:
space 'COBL-AUFNR' aux_gs_file-aufnr.
ENDIF.
IF NOT gs_file-posid IS INITIAL.
PERFORM fill_screen USING:
space 'COBL-PS_POSID' aux_gs_file-posid.
ENDIF.
PERFORM fill_screen USING:
'X' 'SAPMF05A' '0302',
space 'BDC_OKCODE' '/00',
space 'BSEG-WRBTR' aux_gs_file-wrbtr,
space 'BSEG-ZUONR' aux_gs_file-zuonr,
space 'BSEG-SGTXT' aux_gs_file-sgtxt,
space 'BSEG-MWSKZ' aux_gs_file-mwskz.
CLEAR l_mod.
l_mod = l_cont + 1.
READ TABLE gt_file1 INTO gs_file1 INDEX l_mod.
IF sy-subrc = 0.
PERFORM fill_screen USING:
space 'RF05A-NEWBS' gs_file1-bschl1,
space 'RF05A-NEWKO' gs_file1-hkont.
SELECT * INTO TABLE lt_lfbw
FROM lfbw
WHERE lifnr = aux_gs_file-lifnr AND
wt_subjct = 'X'.
IF sy-subrc = 0.
PERFORM fill_screen USING:
'X' 'SAPLFWTD' '0100',
space 'BDC_OKCODE' '=GO'.
CLEAR: ln2, wcampo, wcampo1.
...