USE FOR ALL ENTRIES IN IN SAP ABAP
REPORT ZJOINQUERY.
TYPES: BEGIN OF ty_LIKP,
VBELN TYPE VBELN_VL,
ERZET TYPE ERZET,
ERNAM TYPE ERNAM,
END OF ty_LIKP,
BEGIN OF ty_LIPS,
VBELN TYPE VBELN_VL,
POSNR TYPE POSNR_VL,
PSTYV TYPE PSTYV_VL,
END OF ty_LIPS,
BEGIN OF ty_final,
VBELN TYPE VBELN_VL,
ERZET TYPE ERZET,
ERNAM TYPE ERNAM,
POSNR TYPE POSNR_VL,
PSTYV TYPE PSTYV_VL,
END OF ty_final.
DATA: it_LIKP TYPE STANDARD TABLE OF ty_LIKP,
wa_LIKP TYPE ty_LIKP,
it_LIPS TYPE STANDARD TABLE OF ty_LIPS,
wa_LIPS TYPE ty_LIPS,
it_final TYPE STANDARD TABLE OF ty_final,
wa_final TYPE ty_final,
gv_vbeln TYPE vbeln_vL.
SELECTION-SCREEN BEGIN OF BLOCK s WITH FRAME TITLE text-009.
SELECT-OPTIONS: s_vbeln FOR gv_vbeln.
SELECTION-SCREEN END OF BLOCK s.
START-OF-SELECTION.
SELECT VBELN
ERZET
ERNAM
FROM LIKP INTO TABLE it_LIKP
WHERE vbeln IN s_vbeln.
IF sy-subrc = 0.
SORT it_LIKP BY vbeln.
ENDIF.
IF it_LIKP IS NOT INITIAL.
SELECT VBELN
POSNR
PSTYV
FROM LIPS INTO TABLE it_LIPS
FOR ALL ENTRIES IN it_LIKP
WHERE vbeln = it_LIKP-vbeln.
IF sy-subrc = 0.
SORT it_LIPS BY vbeln.
ENDIF.
ENDIF.
LOOP AT it_LIPS INTO wa_LIPS.
wa_final-vbeln = wa_LIPS-vbeln.
wa_final-POSNR = wa_LIPS-POSNR.
wa_final-PSTYV = wa_LIPS-PSTYV .
READ TABLE it_LIKP INTO wa_LIKP
WITH KEY vbeln = wa_LIKP-VBELN.
IF sy-subrc = 0.
wa_final-ERZET = wa_LIKP-ERZET.
wa_final-ERNAM = wa_LIKP-ERNAM.
ENDIF.
APPEND wa_final TO it_final.
CLEAR : wa_final , wa_LIPS , wa_LIKP.
endloop.
LOOP AT it_final into wa_final.
WRITE:/ wa_final-vbeln,
wa_final-ERZET,
wa_final-ERNAM,
wa_final-posnr,
wa_final-PSTYV.
.
ENDLOOP.
REPORT ZJOINQUERY.
TYPES: BEGIN OF ty_LIKP,
VBELN TYPE VBELN_VL,
ERZET TYPE ERZET,
ERNAM TYPE ERNAM,
END OF ty_LIKP,
BEGIN OF ty_LIPS,
VBELN TYPE VBELN_VL,
POSNR TYPE POSNR_VL,
PSTYV TYPE PSTYV_VL,
END OF ty_LIPS,
BEGIN OF ty_final,
VBELN TYPE VBELN_VL,
ERZET TYPE ERZET,
ERNAM TYPE ERNAM,
POSNR TYPE POSNR_VL,
PSTYV TYPE PSTYV_VL,
END OF ty_final.
DATA: it_LIKP TYPE STANDARD TABLE OF ty_LIKP,
wa_LIKP TYPE ty_LIKP,
it_LIPS TYPE STANDARD TABLE OF ty_LIPS,
wa_LIPS TYPE ty_LIPS,
it_final TYPE STANDARD TABLE OF ty_final,
wa_final TYPE ty_final,
gv_vbeln TYPE vbeln_vL.
SELECTION-SCREEN BEGIN OF BLOCK s WITH FRAME TITLE text-009.
SELECT-OPTIONS: s_vbeln FOR gv_vbeln.
SELECTION-SCREEN END OF BLOCK s.
START-OF-SELECTION.
SELECT VBELN
ERZET
ERNAM
FROM LIKP INTO TABLE it_LIKP
WHERE vbeln IN s_vbeln.
IF sy-subrc = 0.
SORT it_LIKP BY vbeln.
ENDIF.
IF it_LIKP IS NOT INITIAL.
SELECT VBELN
POSNR
PSTYV
FROM LIPS INTO TABLE it_LIPS
FOR ALL ENTRIES IN it_LIKP
WHERE vbeln = it_LIKP-vbeln.
IF sy-subrc = 0.
SORT it_LIPS BY vbeln.
ENDIF.
ENDIF.
LOOP AT it_LIPS INTO wa_LIPS.
wa_final-vbeln = wa_LIPS-vbeln.
wa_final-POSNR = wa_LIPS-POSNR.
wa_final-PSTYV = wa_LIPS-PSTYV .
READ TABLE it_LIKP INTO wa_LIKP
WITH KEY vbeln = wa_LIKP-VBELN.
IF sy-subrc = 0.
wa_final-ERZET = wa_LIKP-ERZET.
wa_final-ERNAM = wa_LIKP-ERNAM.
ENDIF.
APPEND wa_final TO it_final.
CLEAR : wa_final , wa_LIPS , wa_LIKP.
endloop.
LOOP AT it_final into wa_final.
WRITE:/ wa_final-vbeln,
wa_final-ERZET,
wa_final-ERNAM,
wa_final-posnr,
wa_final-PSTYV.
.
ENDLOOP.
No comments:
Post a Comment