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

Select Query

Former Member
0 Likes
434

hi experts.

Below is my code for fetching invoice condition values.

I am fetching condtion types from a table called zsd80 in an internal table i_zsd80. based on this table i have to fetch condition values from konv table. but i am not able to do it. how because i can not use for all entries at 2 times.

please help me.i am stucked in between 3rd and 4th select statements.

SELECT vbrk~vbeln
         vbrk~knumv
         vbrk~fkdat
         vbrk~regio
         vbrk~kunag
         vbrp~posnr
         vbrp~fkimg
         vbrp~aubel
    FROM vbrk INNER JOIN vbrp
      ON vbrk~vbeln EQ vbrp~vbeln
    INTO CORRESPONDING FIELDS OF TABLE i_vbrk
   WHERE vbrk~fkdat IN s_period.
*     AND regio IN s_region
*     AND kunag EQ p_kunag.
  IF sy-subrc EQ 0.
    SELECT vbeln
           posnr
           meins
           matnr
           arktx
           werks
           netwr
           mvgr2
           charg
      FROM vbap
      INTO TABLE i_vbap
       FOR ALL ENTRIES IN i_vbrk
     WHERE vbeln = i_vbrk-vbeln
       AND posnr = i_vbrk-posnr
       AND werks IN s_plant.
    IF sy-subrc EQ 0.

*Get condition type for invoices
      Select *
        from zsd80
        into table i_zsd80
       where tcodes = 'ZVR80'.
       
*Get condition value for invoices
      SELECT knumv
             kposn
             kschl
             kbetr
             waers
             kwert
             kmein
        FROM konv
        INTO TABLE i_konv
         FOR ALL ENTRIES IN i_vbrk
       WHERE knumv = i_vbrk-knumv
         AND kposn = i_vbrk-posnr.

      IF sy-subrc EQ 0.
        SORT i_konv BY knumv kposn kschl.
      ENDIF.
    ELSE.
      MESSAGE text-004 TYPE 'E'.
    ENDIF.
  ENDIF.

Thank you

2 REPLIES 2
Read only

Former Member
0 Likes
359

Hi,

What is the relation between KONV and ZSD80 table.

If this two tables can be linked properly then you can use

inner join followed by for all entries in your 4th select statement.

Then 3rd query for ZSD80 is not required.

Make sure that fields used in joining condition are key fields/indexed fields

for performance issue.

Regards,

Vishal

Read only

Former Member
0 Likes
359

Hi,

what u have to do is...declarea another internal table with required fields and loop through i_vbrk and inbetween loop and endloop use read statement and move data to to ur final internal table.