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:Β 

Regarding report

Former Member
0 Kudos

Hi Experts

I am fetching data from Table vbak ,vbap, konv and i am not getting the output.This is my coding.

TABLES:VBAP,VBAK,KONV.

DATA KNUMV LIKE VBAK-KNUMV.

DATA:BEGIN OF ITAB OCCURS 0,

KUNNR LIKE VBAK-KUNNR,

VBELN LIKE VBAK-VBELN,

POSNR LIKE VBAP-POSNR,

MATNR LIKE VBAP-MATNR,

NETPR LIKE VBAP-NETPR,

BSTDK LIKE VBAK-BSTDK,

KNUMV LIKE VBAK-KNUMV,

END OF ITAB.

DATA PTAB LIKE KONV OCCURS 0 WITH HEADER LINE.

DATA : BEGIN OF FTAB OCCURS 0 ,

KUNNR LIKE VBAK-KUNNR,

VBELN LIKE VBAK-VBELN,

POSNR LIKE VBAP-POSNR,

MATNR LIKE VBAP-MATNR,

NETPR LIKE VBAP-NETPR,

BSTDK LIKE VBAK-BSTDK,

KBETR LIKE KONV-KBETR,

KNTYP LIKE KONV-KNTYP,

KNUMV LIKE VBAK-KNUMV,

END OF FTAB.

PARAMETER P_KUNNR LIKE VBAK-KUNNR OBLIGATORY.

SELECT-OPTIONS D_DATE FOR VBAK-BSTDK.

SELECT AKUNNR AVBELN AERDAT BPOSNR BMATNR BNETPR INTO CORRESPONDING FIELDS OF TABLE ITAB FROM VBAK AS A INNER JOIN VBAP AS B ON

( AVBELN = BVBELN ) WHERE KUNNR = P_KUNNR AND BSTDK IN D_DATE.

SELECT KBETR KNTYP FROM KONV INTO CORRESPONDING FIELDS OF TABLE PTAB FOR ALL ENTRIES IN ITAB WHERE KNUMV = ITAB-KNUMV.

MOVE-CORRESPONDING ITAB TO FTAB.

MOVE-CORRESPONDING PTAB TO FTAB.

LOOP AT FTAB.

WRITE πŸ˜• FTAB-KUNNR, FTAB-VBELN, FTAB-POSNR, FTAB-MATNR, FTAB-NETPR, FTAB-BSTDK, FTAB-KBETR, FTAB-KNTYP.

ENDLOOP.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi prakash,

1. Minor mistake.

2. Instead of

MOVE-CORRESPONDING ITAB TO FTAB.

MOVE-CORRESPONDING PTAB TO FTAB.

3. It should be like this.

<b>LOOP AT ITAB.

MOVE-CORRESPONDING ITAB TO FTAB.

APPEND FTAB.

ENDLOOP.

LOOP AT PTAB.

MOVE-CORRESPONDING PTAB TO FTAB.

APPEND FTAB.

ENDLOOP.</b>

regards,

amit m.

7 REPLIES 7

Former Member
0 Kudos

Hi prakash,

1. Minor mistake.

2. Instead of

MOVE-CORRESPONDING ITAB TO FTAB.

MOVE-CORRESPONDING PTAB TO FTAB.

3. It should be like this.

<b>LOOP AT ITAB.

MOVE-CORRESPONDING ITAB TO FTAB.

APPEND FTAB.

ENDLOOP.

LOOP AT PTAB.

MOVE-CORRESPONDING PTAB TO FTAB.

APPEND FTAB.

ENDLOOP.</b>

regards,

amit m.

former_member188827
Active Contributor
0 Kudos

after move-corresponding use append

Message was edited by:

abapuser

Former Member
0 Kudos

Hi

Declare KNUMV field in both internal tables ITAB and PTAB and fetch it from VBAK into ITAB and KONV into PTAB.

then write the following

loop at itab.

move-corresponding itab to ftab.

read table ptab with key knumv = itab-knumv.

if sy-subrc = 0.

move-corresponding ptab to ftab.

endif.

append ftab.

clear ftab.

endloop.

loop at ftab.

write:/ all fields of ftab.

endloop.

<b>Reward points for useful Answers</b>

Regards

Anji

Former Member
0 Kudos

Hi,

Are u sure,the Table contains the Values for the Input given by u.

Set Break-point in the Select Query & check it whether there is Values for given input or not.

Regards,

Padmam.

raymond_giuseppi
Active Contributor
0 Kudos

Try

  TABLES:vbap,vbak,konv.
  DATA knumv LIKE vbak-knumv.
  DATA:BEGIN OF itab OCCURS 0,
  kunnr LIKE vbak-kunnr,
  vbeln LIKE vbak-vbeln,
  posnr LIKE vbap-posnr,
  matnr LIKE vbap-matnr,
  netpr LIKE vbap-netpr,
  bstdk LIKE vbak-bstdk,
  knumv LIKE vbak-knumv,
  END OF itab.

  DATA ptab LIKE konv OCCURS 0 WITH HEADER LINE.

  DATA : BEGIN OF ftab OCCURS 0 ,
  kunnr LIKE vbak-kunnr,
  vbeln LIKE vbak-vbeln,
  posnr LIKE vbap-posnr,
  matnr LIKE vbap-matnr,
  netpr LIKE vbap-netpr,
  bstdk LIKE vbak-bstdk,
  kbetr LIKE konv-kbetr,
  kntyp LIKE konv-kntyp,
  knumv LIKE vbak-knumv,
  END OF ftab.

  PARAMETER p_kunnr LIKE vbak-kunnr OBLIGATORY.
  SELECT-OPTIONS d_date FOR vbak-bstdk.

  SELECT a~kunnr a~vbeln a~erdat b~posnr b~matnr b~netpr 
    INTO CORRESPONDING FIELDS OF TABLE itab 
    FROM vbak AS a INNER JOIN vbap AS b ON
    ( a~vbeln = b~vbeln ) WHERE kunnr = p_kunnr AND bstdk IN d_date.

  SELECT knumv kbetr kntyp FROM konv INTO CORRESPONDING FIELDS OF TABLE
    ptab FOR ALL ENTRIES IN itab WHERE knumv = itab-knumv.

  LOOP AT itab.
    MOVE-CORRESPONDING itab TO ftab.
    LOOP AT ptab WHERE knumv = itab-knumv.
      MOVE-CORRESPONDING ptab TO ftab.
      APPEND ftab.
    ENDLOOP.
  ENDLOOP.

  LOOP AT ftab.

    WRITE πŸ˜• ftab-kunnr, ftab-vbeln, ftab-posnr, ftab-matnr, ftab-netpr,
      ftab-bstdk, ftab-kbetr, ftab-kntyp.
  ENDLOOP.

Regards

Former Member
0 Kudos

Hi,

MOVE-CORRESPONDING ITAB TO FTAB.

MOVE-CORRESPONDING PTAB TO FTAB

By using these move statements only header lines of the tables are moved not the table contents.

So better using [] beside table names whilw refering to table contents.

Use ITAB[] , FTAb[], PTAB[].

Regards,

Sankar

Former Member
0 Kudos

Hi,

U have declared KNUMV in ITAB, but u haven't selected KNUMV from VBAK table in the first query.

1.Select KNUMV field in the first query, set break-point and check whether KNUMV field value is taken.

2. Give the second query within loop.

Loop at itab.

endloop.

select KNUMV in this second query, set break-point an check whether KNUMV field value is taken.

3.Then give loop

loop at itab.

move-corresponding itab to ftab.

read table ptab with key knumv = itab-knumv.

if sy-subrc = 0.

move-corresponding ptab to ftab.

endif.

append ftab.

clear ftab.

endloop.

Regards,

Sathya Rajkumar.