Skip to Content
0
Mar 28, 2010 at 01:18 PM

Select Statment run 3 times !!

35 Views

Hi, I have the following code, when i run the program am getting correct result but 3 times

can you help me? it is problem with the Join or ,,,?

TABLES: ekko,ekpo,ekbe,rbkp.

data: BEGIN OF itab OCCURS 0, "

bukrs like ekko-bukrs,

ebeln like ekko-ebeln,

aedat like ekko-aedat,

bsart like ekko-bsart,

ekgrp like ekko-ekgrp,

inco1 like ekko-inco1,

inco2 like ekko-inco2,

lifnr like ekko-lifnr,

waers like ekko-waers,

wkurs like ekko-wkurs,

ernam like ekko-ernam,

BRTWR LIKE ekpo-brtwr,

belnr like EKBE-belnr,

BEWTP LIKE EKBE-BEWTP,

"EKPO TABLE

end of itab.

AT SELECTION-SCREEN on s_bukrs.

  • if s_bukrs = '1000' or '2000' .

START-OF-SELECTION.

SELECT ekkobukrs ekkoebeln ekkoaedat ekkobsart ekkoekgrp ekkolifnr ekkowaers ekkowkurs ekkoernam ekpobrtwr EKBEbelnr EKBEbewtp

into CORRESPONDING FIELDS OF TABLE itab from ekko

inner join EKPO on ekPOEBELN = ekkoebeln

Inner Join EKBE on EKBEEBELN = ekPOEBELN

WHERE ekkobukrs IN S_bukrs AND ekkobsart IN s_bsart AND ekkoebeln IN s_ebeln AND EKBEbewtp EQ 'E'.

END-OF-SELECTION.

"SORT ITAB BY EBELN ascending.

LOOP AT ITAB .

"move-corresponding line to line1.

write:/

ITAB-bukrs under 'Company Code',

ITAB-ebeln UNDER 'PO-Number',

ITAB-aedat UNDER 'Date' ,

ITAB-bsart UNDER 'Doc-Type' ,

ITAB-ekgrp UNDER 'Purchase-Grp' ,

ITAB-lifnr UNDER 'Vendor' ,

ITAB-waers UNDER 'Currency',

ITAB-wkurs UNDER 'Rate' ,

ITAB-brtwr under 'Gross Value',

ITAB-ernam UNDER 'Created By',

ITAB-belnr UNDER 'Material Doc NO',

ITAB-bewtp Under 'HCT'.

EndLoop .

*write:/5 'Purchase-Order',25 'Date',40 'Material Document',60 'Hct'.

*uline.

*skip.

write:/5 'Company Code',25 'PO-Number',40 'Date',55 'Doc-Type',70 'Purchase-Grp',85 'Vendor',100 'Currency',115 'Rate',125 'Created By',

140 'Gross Value', 160 'Material Doc NO' , 175 'HCT'.

ULINE.

SKIP.