Application Development 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: 

Output of the program

Former Member
0 Kudos

Hi,

I wrote a program to retrieve data from three different master data tables but not getting the desired output. The output comes all in zeroes.

Can anyone tell me where am I going wrong?

Here is the code-

REPORT ZREPORT1 .

Tables: PA0002, PA0008, PA0015.

data : begin of itab occurs 0,

CLIENTNO LIKE PA0002-MANDT,

ENAME TYPE PA0002-CNAME,

ESAL TYPE PA0008-ANSAL,

OT TYPE PA0015-BETRG,

ENO LIKE PA0002-PERNR,

END OF ITAB.

SELECT A~CNAME

A~PERNR

A~MANDT

B~ANSAL

B~PERNR

C~BETRG

C~PERNR

INTO CORRESPONDING FIELDS OF TABLE itab

FROM ( PA0002 AS A INNER JOIN PA0008 AS B

ON APERNR = BPERNR )

INNER JOIN PA0015 AS C

ON BPERNR = CPERNR

WHERE A~MANDT = 800.

LOOP AT itab.

WRITE: / ITAB-CLIENTNO, 25 ITAB-ESAL ,45 ITAB-OT.

ENDLOOP.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi ,

u have to put like this .

SELECT A~CNAME

A~PERNR

A~MANDT <b>as clientNo</b>

B~ANSAL <b>as esal</b>

B~PERNR

C~BETRG <b>as OT</b>

C~PERNR

INTO CORRESPONDING FIELDS OF TABLE itab

FROM ( PA0002 AS A INNER JOIN PA0008 AS B

ON APERNR = BPERNR )

INNER JOIN PA0015 AS C

ON BPERNR = CPERNR

WHERE A~MANDT = 800.

LOOP AT itab.

WRITE: / ITAB-CLIENTNO, 25 ITAB-ESAL ,45 ITAB-OT.

ENDLOOP.

Regards

Prabhu

5 REPLIES 5

Former Member
0 Kudos

Hi ,

u have to put like this .

SELECT A~CNAME

A~PERNR

A~MANDT <b>as clientNo</b>

B~ANSAL <b>as esal</b>

B~PERNR

C~BETRG <b>as OT</b>

C~PERNR

INTO CORRESPONDING FIELDS OF TABLE itab

FROM ( PA0002 AS A INNER JOIN PA0008 AS B

ON APERNR = BPERNR )

INNER JOIN PA0015 AS C

ON BPERNR = CPERNR

WHERE A~MANDT = 800.

LOOP AT itab.

WRITE: / ITAB-CLIENTNO, 25 ITAB-ESAL ,45 ITAB-OT.

ENDLOOP.

Regards

Prabhu

Former Member
0 Kudos

u write <b>A~MANDT = 800</b>.check it i think there is some thing.... clnt field.

MANDT MANDT CLNT 3 0 Client

0 Kudos

Thanks a lot Prabhu. My problem is solved.

Former Member
0 Kudos

Joining 3-4 tables can sometimes be erroneous and it is tough to find out the error. Can you please use 3-4 separate 'SELECT' clause with 'FOR ALL ENTRIES'. I am sure this will be helpful.

Regards,

Subhasish

Former Member
0 Kudos

Hi,

INTO CORRESPONIDING fields is failing because the field names are not matcing.

declare your itab as

data : begin of itab occurs 0,

mandt LIKE PA0002-MANDT,

cNAME TYPE PA0002-CNAME,

anSAL TYPE PA0008-ANSAL,

betrg TYPE PA0015-BETRG,

pernr LIKE PA0002-PERNR,

END OF ITAB.

also, modify the WRITE statement accordingly.

Regards,

Shashank