You are on page 1of 4

*&---------------------------------------------------------------------* *& Report ZREPORT2 *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* report zreport2. type-POOLs: slis. tables: ekko,ekpo,ekbe,lfa1,makt,mkpf.

types : begin of fs, ebeln type ekko-ebeln, lifnr type ekko-lifnr, bedat type ekko-bedat, end of fs. types: begin of fs1, ebeln type ekpo-ebeln, ebelp type ekpo-ebelp, matnr type ekpo-matnr, end of fs1. types : begin of fs2, ebeln type ekbe-ebeln, menge type ekbe-menge, werks type ekbe-werks, wrbtr type ekbe-wrbtr, budat type ekbe-budat, belnr type ekbe-belnr, end of fs2. types: begin of fs3, lifnr type lfa1-lifnr, name1 type lfa1-name1, end of fs3. types : begin of fs4, ebeln type ebeln, bedat type bedat, ebelp type ebelp, lifnr type lifnr, name1 type name1_gp, xabln type xabln, budat type budat, matnr type matnr, maktx type maktx, menge type ekbe-menge, wrbtr type wrbtr, end of fs4. types: begin of fs5, matnr type makt-matnr, maktx type makt-maktx, end of fs5. types: begin of fs6, xabln type mkpf-xabln, end of fs6. data : it type standard table of fs, wa like line of it, it1 type standard table of fs1 ,wa1 like line of it1, it2 type standard table of fs2 ,wa2 like line of it2,

it3 type standard table of fs3 ,wa3 it4 type standard table of fs4 ,wa4 it5 type standard table of fs5 ,wa5 it6 type standard table of fs6 ,wa6 parameters : c type ebeln. select-options a for wa-bedat . select-options b for wa2-werks . start-of-selection. IF c is initial and a is initial. select ebeln lifnr bedat from ekko into table it. elseif c is initial. select ebeln lifnr bedat from ekko into table it where bedat in a. else. select ebeln lifnr bedat from ekko into table it where ebeln = c . ENDIF.

like like like like

line line line line

of of of of

it3, it4, it5, it6.

select ebeln ebelp matnr from ekpo into table it1 for all entries in it where e beln = it-ebeln. IF b is initial. select ebeln menge it1 where ebeln = else. select ebeln menge it1 where ebeln = ENDIF. werks wrbtr budat into table it2 from ekbe for all entries in it1-ebeln. werks wrbtr budat into table it2 from ekbe for all entries in it1-ebeln and werks in b.

select lifnr name1 from lfa1 into table it3 for all entries in it where lifnr = it-lifnr. select matnr maktx from makt into table it5 for all entries in it1 where matnr = it1-matnr. select xabln from mkpf into table it6 for all entries in it2 where mblnr = it2-b elnr. data : c1 type i,c2 type i,c3 type i,c4 type i,c5 type i,c6 type i. describe describe describe describe describe describe table table table table table table it lines c1. it1 lines c2. it2 lines c3. it3 lines c4. it5 lines c5. it6 lines c6.

types : begin of fs7, num type i, end of fs7. data : it7 type table of fs7 , wa7 type fs7.

wa7-num = c1. append wa7 to wa7-num = c2. append wa7 to wa7-num = c3. append wa7 to wa7-num = c4. append wa7 to wa7-num = c5. append wa7 to wa7-num = c6. append wa7 to

it7. it7. it7. it7. it7. it7.

data : sum type i value 0. loop at it7 into wa7. if wa7-num gt sum. sum = wa7-num. endif. endloop. do sum times. read table it into wa index sy-tabix. read table it1 into wa1 index sy-tabix. read table it2 into wa2 index sy-tabix. read table it3 into wa3 index sy-tabix. read table it5 into wa5 index sy-tabix. read table it6 into wa6 index sy-tabix. wa4-ebeln = wa-ebeln. wa4-bedat = wa-bedat. wa4-ebelp = wa1-ebelp. wa4-lifnr = wa-lifnr. wa4-name1 = wa3-name1. wa4-xabln = wa6-xabln. wa4-budat = wa2-budat. wa4-matnr = wa5-matnr. wa4-maktx = wa5-maktx. wa4-menge = wa2-menge. wa4-wrbtr = wa2-wrbtr. append wa4 to it4. enddo. sort it4 ascending. delete adjacent duplicates from it4 comparing ebeln lifnr matnr. end-of-selection. *LOOP AT it4 into wa4. *write:/ wa4-ebeln,wa4-bedat,wa4-ebelp,wa4-lifnr,wa4-name1,wa4-xabln,wa4-budat,w a4-matnr,wa4-maktx,wa4-menge,wa4-wrbtr. *ENDLOOP. DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV, WA_FCAT LIKE LINE OF IT_FCAT. call function 'REUSE_ALV_FIELDCATALOG_MERGE' EXPORTING I_PROGRAM_NAME = SY-repid I_INTERNAL_TABNAME = 'FS4' * I_STRUCTURE_NAME = 'FS4' * I_CLIENT_NEVER_DISPLAY = 'X' I_INCLNAME = sy-repid

* *

I_BYPASSING_BUFFER = I_BUFFER_ACTIVE = changing ct_fieldcat = it_fcat * EXCEPTIONS * INCONSISTENT_INTERFACE = 1 * PROGRAM_ERROR = 2 * OTHERS = 3 . call function 'REUSE_ALV_GRID_DISPLAY' EXPORTING * I_INTERFACE_CHECK = ' ' * I_BYPASSING_BUFFER = ' ' * I_BUFFER_ACTIVE = ' ' I_CALLBACK_PROGRAM = sy-repid * I_CALLBACK_PF_STATUS_SET = ' ' * I_CALLBACK_USER_COMMAND = ' ' * I_CALLBACK_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_END_OF_LIST = ' ' I_STRUCTURE_NAME = 'FS4' * I_BACKGROUND_ID = ' ' I_GRID_TITLE = 'PURCHASE DOCUMENT REPORT' * I_GRID_SETTINGS = * IS_LAYOUT = * IT_FIELDCAT = 'IT_FCAT' * IT_EXCLUDING = * IT_SPECIAL_GROUPS = * IT_SORT = * IT_FILTER = * IS_SEL_HIDE = * I_DEFAULT = 'X' * I_SAVE = ' ' * IS_VARIANT = * IT_EVENTS = * IT_EVENT_EXIT = * IS_PRINT = * IS_REPREP_ID = * I_SCREEN_START_COLUMN = 0 * I_SCREEN_START_LINE = 0 * I_SCREEN_END_COLUMN = 0 * I_SCREEN_END_LINE = 0 * I_HTML_HEIGHT_TOP = 0 * I_HTML_HEIGHT_END = 0 * IT_ALV_GRAPHICS = * IT_HYPERLINK = * IT_ADD_FIELDCAT = * IT_EXCEPT_QINFO = * IR_SALV_FULLSCREEN_ADAPTER = * IMPORTING * E_EXIT_CAUSED_BY_CALLER = * ES_EXIT_CAUSED_BY_USER = tables t_outtab = IT4 * EXCEPTIONS * PROGRAM_ERROR = 1 * OTHERS = 2 .

You might also like