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

problem in field selection in IR

Former Member
0 Likes
925

hello friends,

i am making an interactive report.

in case statment...........


SELECT * FROM VBAP INTO CORRESPONDING FIELDS OF TABLE IT_FINAL
               WHERE VBELN = IT_FINAL-VBELN.
              SELECT ERZET AUDAT AUART FROM VBAK INTO CORRESPONDING FIELDS OF TABLE IT_FINAL     WHERE VBELN = IT_FINAL.

in above query when first query gets executed i get the values in corresponding fields in it_final.

but no sooner did 2nd select stament gets executed the values which have come from vbap into it_final ,disappears........only values from vbak remains in it_final

the structure of it_final is.........


DATA: BEGIN OF IT_FINAL OCCURS 0,
      VBELN   LIKE VBAP-VBELN,
      POSNR   LIKE VBAP-POSNR,
      MATNR   LIKE VBAP-MATNR,
      CHARG   LIKE VBAP-CHARG,
      MATKL   LIKE VBAP-MATKL,
      ERZET   LIKE VBAK-ERZET,
      AUDAT   LIKE VBAK-AUDAT,
      TRVOG   LIKE VBAK-TRVOG,
      AUART   LIKE VBAK-AUART,
     END OF IT_FINAL.

plz help.

regards

mukesh.

Edited by: Mukesh Yadav on Jan 7, 2009 9:03 AM

Code Formatted by: Alvaro Tejada Galindo on Jan 7, 2009 3:19 PM

1 ACCEPTED SOLUTION
Read only

Sm1tje
Active Contributor
0 Likes
900

use appending corresponding fields...

hello friends,

i am making an interactive report.

in case statment...........


SELECT * FROM VBAP INTO CORRESPONDING FIELDS OF TABLE IT_FINAL
               WHERE VBELN = IT_FINAL-VBELN.
              SELECT ERZET AUDAT AUART FROM VBAK INTO CORRESPONDING FIELDS OF TABLE IT_FINAL     WHERE VBELN = IT_FINAL.

in above query when first query gets executed i get the values in corresponding fields in it_final.

but no sooner did 2nd select stament gets executed the values which have come from vbap into it_final ,disappears........only values from vbak remains in it_final

the structure of it_final is.........


DATA: BEGIN OF IT_FINAL OCCURS 0,
      VBELN   LIKE VBAP-VBELN,
      POSNR   LIKE VBAP-POSNR,
      MATNR   LIKE VBAP-MATNR,
      CHARG   LIKE VBAP-CHARG,
      MATKL   LIKE VBAP-MATKL,
      ERZET   LIKE VBAK-ERZET,
      AUDAT   LIKE VBAK-AUDAT,
      TRVOG   LIKE VBAK-TRVOG,
      AUART   LIKE VBAK-AUART,
     END OF IT_FINAL.

plz help.

regards

mukesh.

Edited by: Mukesh Yadav on Jan 7, 2009 9:03 AM

Code Formatted by: Alvaro Tejada Galindo on Jan 7, 2009 3:19 PM

5 REPLIES 5
Read only

Sm1tje
Active Contributor
0 Likes
901

use appending corresponding fields...

Read only

Former Member
0 Likes
900

Hi,

Yes, it will happen like this only coz you are using the same internal table and only last query data gets filled in the table..

Better option would be either you move the data to temporary table and then by using loop transfer the dat again to maintable or you can also use JOIN query..

example of join query would be like this 4 your rquirment..

select vbakERZET vbakAUDAT vbakAUART vbap....your reuired fields

from vbap inner join vbak on "common priamry feilds of both table" where condition.

see F1 help on join query

Regards

Mudit

Read only

Former Member
0 Likes
900

Hi,

Issue in your Code:


SELECT * FROM VBAP INTO CORRESPONDING FIELDS OF TABLE IT_FINAL
WHERE VBELN = IT_FINAL-VBELN.

SELECT ERZET AUDAT AUART FROM VBAK INTO CORRESPONDING FIELDS OF TABLE IT_FINAL WHERE VBELN = IT_FINAL.

You are Reading from the Same intrenal Table and filling the results in the same Internal Table.

Please correct it first and you will get rid of your problem..

Code Formatted by: Alvaro Tejada Galindo on Jan 7, 2009 3:20 PM

Read only

Former Member
0 Likes
900

Hi Mukesh,

When the second query is been executed it fills the IT_FINAL with new values come from VBAK and

previous values will get lost.

If you want to retain the previous values rewrite the second select query as

SELECT erzet audat auart FROM vbak
  APPENDING CORRESPONDING FIELDS OF TABLE it_final
  WHERE vbeln = it_final-vbeln.

In case you don't want to append, but you need to modify the entries for existing documents, then

declare another table as

DATA: BEGIN OF it_vbak OCCURS 0,
vbeln LIKE vbap-vbeln,
erzet LIKE vbak-erzet,
audat LIKE vbak-audat,
auart LIKE vbak-auart,
END OF it_vbak.

then change the logic as

SELECT erzet audat auart FROM vbak
  APPENDING CORRESPONDING FIELDS OF TABLE it_vbak "Storing values into 
                                                  "new table
  FOR ALL ENTRIES IN it_final
  WHERE vbeln = it_final-vbeln.

LOOP AT it_final.
  READ TABLE it_vbak WITH KEY vbeln = it_final-vbeln.
  IF sy-subrc EQ 0.
    it_final-erzet = it_vbak-erzet.
    it_final-audat = it_vbak-audat.
    it_final-auart = it_vbak-auart.
    MODIFY it_final. "Modifying the values for existing vbeln from vbak
  ENDIF.
ENDLOOP.

Hope this will help you.

Regards,

Manoj Kumar P

Read only

Former Member
0 Likes
900

Try this code

select vbeln --- from vbap into corresponding fields of it_final.

select vbeln --- from vbak appending corresponding fields of it_final.

Hope this will help you.

Thanks,

Kishore