Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

help required

Former Member
0 Likes
331

can anyone helping me writing the code for this?

Also please explain me how do we use select statements when we have data to be retrieved from many tables..

Read table of deliveries LIKP (header level) based in selection screen:

Sales organization = LIKP-VKORG

Actual good movement date from the delivery = LIKP- WADAT_IST

Read table of deliveries LIPS (item level). The common fields are:

LIKP-VBELN = LIPS-VBELN

Read table of sales orders VBAK (header level). The common fields are:

LIPS-VGBEL = VBAP-VBELN.

LIPS-VGPOS = VBAP-POSNR.

Read table customers master to retrieve the name KNA1-NAME1.

Read table vendors master to retrieve the name LFA1-NAME1.

Read table KONV to retrieve the transport costs of each sales order. The common fields are:

VBAK-KNUMV = KONV-KNUMV

VBAP-POSNR = KONV-KPOSN

If KONV-KSCHL = ‘ZGC1’

Transport cost 1 (ZGC1) = KONV-KBETR.

If KONV-KSCHL = ‘ZGC2’

Transport cost 2 (ZGC2) = KONV-KBETR.

IF KONV-KSCHL = ‘ZGC3’

Transport cost 3 (ZGC3) = KONV-KBETR

1 REPLY 1
Read only

Former Member
0 Likes
292

Hi better you move each database table value into separate itab,after that using common field you move data from one itab to final internal table.

you declare final itab having all the filed you want to display.

for example here i have send one program..

-


&----


*

& Report ZMULTIREPORT *

& *

&----


*

& *

& *

&----


*

REPORT ZMULTIREPORT .

TABLE DECLARATION.

TABLES: VBAK,VBAP,KNA1,MARA.

TYPE-POOLS SLIS.

INTERNAL TABLE DECLARATION.

DATA : BEGIN OF ITAB1_VBAK OCCURS 0,

VBELN LIKE VBAK-VBELN,

ERDAT LIKE VBAK-ERDAT,

ERNAM LIKE VBAK-ERNAM,

END OF ITAB1_VBAK.

DATA : BEGIN OF ITAB2_VBAP OCCURS 0,

VBELN LIKE VBAP-VBELN,

POSNR LIKE VBAP-POSNR,

MATNR LIKE VBAP-MATNR,

FMENG LIKE VBAP-FMENG,

END OF ITAB2_VBAP.

DATA : BEGIN OF ITAB3_MARA OCCURS 0,

MATNR LIKE MARA-MATNR,

MATKL LIKE MARA-MATKL,

MEINS LIKE MARA-MEINS,

END OF ITAB3_MARA.

DATA : BEGIN OF OUTPUT OCCURS 0,

VBELN LIKE VBAK-VBELN,

ERDAT LIKE VBAK-ERDAT,

ERNAM LIKE VBAK-ERNAM,

POSNR LIKE VBAP-POSNR,

MATNR LIKE VBAP-MATNR,

FMENG LIKE VBAP-FMENG,

MATKL LIKE MARA-MATKL,

MEINS LIKE MARA-MEINS,

END OF OUTPUT.

START OF SELECTION

select-options : P_VBELN for VBAK-VBELN.

SELECT STATEMENT

if p_vbeln is not initial.

SELECT

VBELN

ERDAT

ERNAM

FROM VBAK

INTO TABLE ITAB1_VBAK

WHERE VBELN in P_VBELN.

ENDIF.

IF ITAB1_VBAK[] IS NOT INITIAL.

SELECT

VBELN

POSNR

MATNR

FMENG

FROM VBAP

INTO TABLE ITAB2_VBAP FOR ALL ENTRIES IN ITAB1_VBAK

WHERE VBELN = ITAB1_VBAK-VBELN.

ENDIF.

IF ITAB2_VBAP[] IS NOT INITIAL.

SELECT

MATNR

MATKL

MEINS

FROM MARA

INTO TABLE ITAB3_MARA FOR ALL ENTRIES IN ITAB2_VBAP

WHERE MATNR = ITAB2_VBAP-MATNR.

ENDIF.

*MOVE ALL ITAB VALUE INTO OUTPUT TABLE.

loop at itab1_vbak.

output-vbeln = itab1_vbak-vbeln.

output-erdat = itab1_vbak-erdat.

output-ernam = itab1_vbak-ernam.

clear itab2_vbap.

read table itab2_vbap with key vbeln = itab1_vbak-vbeln.

if sy-subrc = 0.

output-posnr = itab2_vbap-posnr.

output-matnr = itab2_vbap-matnr.

output-fmeng = itab2_vbap-fmeng.

endif.

clear itab3_mara.

read table itab3_mara with key matnr = itab2_vbap-matnr.

if sy-subrc = 0.

output-matkl = itab3_mara-matkl.

output-meins = itab3_mara-meins.

endif.

append output.

endloop.

OUTPUT

WRITE : 015 'DOCNO'(002),

025 'CREATION DATE'(004),

040 'NAME'(006),

060 'ITEM NO'(008),

080 'MATNO'(010),

100 'QUANTITY'(012),

120 'MATGROUP'(014),

140 'BASEUNIT'(016).

uline.

LOOP AT OUTPUT.

WRITE 😕 OUTPUT-VBELN UNDER TEXT-002,

OUTPUT-ERDAT UNDER TEXT-004,

OUTPUT-ERNAM UNDER TEXT-006,

OUTPUT-POSNR UNDER TEXT-008,

OUTPUT-MATNR UNDER TEXT-010,

OUTPUT-FMENG UNDER TEXT-012,

OUTPUT-MATKL UNDER TEXT-014,

OUTPUT-MEINS UNDER TEXT-016.

ENDLOOP.

uline.

-


if it is helpful reward me..

thanks

Gowrishankar