Skip to Content
0
Former Member
Feb 13, 2009 at 01:44 PM

output format at new

18 Views

hi ,

my requirement is at every new lifnr that lifnr no. should be displayed on the top of the output.

TABLES: BSEG,

BKPF,

BSAK,

LFA1.

TYPES : BEGIN OF TY_BSEG,

BELNR LIKE BSEG-BELNR,

BUZEI LIKE BSEG-BUZEI,

BUDAT LIKE BSAK-BUDAT,

HKONT LIKE BSEG-HKONT,

MWSKZ LIKE BSEG-MWSKZ,

WAERS LIKE BSAK-WAERS,

HWAER LIKE BKPF-HWAER,

WRBTR LIKE BSEG-WRBTR,

DMBTR LIKE BSEG-DMBTR,

WMWST LIKE BSEG-WMWST,

MWSTS LIKE BSEG-MWSTS,

LIFNR LIKE LFA1-LIFNR,

NAME1 LIKE LFA1-NAME1,

ORT01 LIKE LFA1-ORT01,

PSTLZ LIKE LFA1-PSTLZ,

EBELN LIKE BSEG-EBELN,

END OF TY_BSEG.

TYPES : BEGIN OF TY_LFA1,

LIFNR TYPE LFA1-LIFNR,

NAME1 TYPE LFA1-NAME1,

ORT01 TYPE LFA1-ORT01,

PSTLZ TYPE LFA1-PSTLZ,

END OF TY_LFA1.

DATA : ITAB TYPE TABLE OF TY_BSEG WITH HEADER LINE.

DATA : IT_LFA1 TYPE TABLE OF TY_LFA1 WITH HEADER LINE .

DATA : IT_FINAL TYPE TABLE OF TY_BSEG WITH HEADER LINE.

SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS: S_BUKRS FOR BSEG-BUKRS,

S_GJAHR FOR BSEG-GJAHR.

SELECTION-SCREEN: END OF BLOCK B1.

SELECTION-SCREEN: BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.

SELECT-OPTIONS: S_LIFNR FOR BSEG-LIFNR,

S_SAKNR FOR BSEG-SAKNR,

S_MWSKZ FOR BSEG-MWSKZ.

SELECTION-SCREEN: END OF BLOCK B2.

START-OF-SELECTION.

PERFORM PREPARE_DATA.

TOP-OF-PAGE.

FORMAT COLOR COL_NEGATIVE INTENSIFIED OFF.

ULINE.

WRITE :/1 SY-VLINE , 5 'BELNR ' , 45 SY-VLINE ,

46 'BUZEI', 56 SY-VLINE ,

57 'BUDAT', 67 SY-VLINE ,

68 'HKONT', 78 SY-VLINE ,

79 'MWSKZ', 89 SY-VLINE ,

90 'WAERS' , 100 SY-VLINE ,

101 'HWAER', 116 SY-VLINE,

117 'DMBTR', 127 SY-VLINE,

128 'NAME1', 160 SY-VLINE.

ULINE.

FORMAT COLOR COL_NEGATIVE OFF.

&----


*& Form PREPARE_DATA

&----


  • text

----


FORM PREPARE_DATA.

SELECT * FROM BSEG INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE

BUKRS IN S_BUKRS AND GJAHR IN S_GJAHR

AND LIFNR IN S_LIFNR AND SAKNR IN S_SAKNR

AND MWSKZ IN S_MWSKZ AND

HKONT IN ('0000534100','0000534200','0000534300')

AND UMSKZ = 'A'.

LOOP AT ITAB.

MOVE-CORRESPONDING ITAB TO IT_FINAL.

APPEND IT_FINAL.

CLEAR IT_FINAL.

ENDLOOP.

SORT IT_FINAL[].

DELETE ADJACENT DUPLICATES FROM IT_FINAL[].

IF NOT IT_FINAL[] IS INITIAL.

SELECT * FROM LFA1 INTO CORRESPONDING FIELDS OF TABLE IT_LFA1

FOR ALL ENTRIES IN IT_FINAL WHERE LIFNR = IT_FINAL-LIFNR.

ENDIF.

LOOP AT IT_FINAL.

READ TABLE IT_LFA1 WITH KEY LIFNR = IT_FINAL-LIFNR.

IF SY-SUBRC = 0.

MOVE IT_LFA1-NAME1 TO IT_FINAL-NAME1.

MOVE IT_LFA1-ORT01 TO IT_FINAL-ORT01.

MOVE IT_LFA1-PSTLZ TO IT_FINAL-PSTLZ.

ENDIF.

MODIFY IT_FINAL.

CLEAR IT_FINAL.

ENDLOOP.

  • LOOP AT IT_FINAL.

  • AT NEW LIFNR.

  • WRITE : / 'VENDOR',IT_FINAL-LIFNR.

  • ENDAT.

  • ENDLOOP.

LOOP AT IT_FINAL.

WRITE:/5 IT_FINAL-BELNR,

46 IT_FINAL-BUZEI,

57 IT_FINAL-BUDAT,

68 IT_FINAL-HKONT,

79 IT_FINAL-MWSKZ,

90 IT_FINAL-WAERS,

101 IT_FINAL-HWAER,

117 IT_FINAL-DMBTR LEFT-JUSTIFIED,

128 IT_FINAL-NAME1.

ENDLOOP.

ENDFORM. "PREPARE_DATA