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
577

HI

Salesorg----


Sales doc----


to -


Period----


to -


Suppose I enter sales org vbak-vkorg as 3050 and give range for sales doc and period it should show all the sales doc in that given range whose

Vbak-auart type is ‘zje’ or ‘zjr’ wrt to the given range period.( only for sales org 3050).

How to write a select query for this.

3 REPLIES 3
Read only

Former Member
0 Likes
535

Hi Daniel,

TABLES:
  VBAK.

SELECT-OPTIONS:
  s_vbeln  FOR vbak-vbeln,
  s_period FOR vbak-agrzr.             " Your Period Field

DATA:
  t_vbak TYPE TABLE OF vbak WITH HEADER LINE.

SELECT *
   FROM vbak
   INTO TABLE t_vbak
 WHERE vbeln IN s_vbeln
   AND agrzr IN s_period               " Your Period Field
   AND auart = 'ZJE'
    OR auart = 'ZJR'
   AND vkorg = '3050'.

LOOP AT t_vbak.
  WRITE:
    /  t_vbak-vbeln,
       t_vbak-kunnr.
ENDLOOP.

Regards,

Sunil

Read only

Former Member
0 Likes
535

Hi,

For ranges first u need to create a structure and u need to populate the values in to that table of ranges.

then only u can use them.

RANGES <rangetab> FOR <f>.

DATA: BEGIN OF <rangetab> OCCURS 0,
         sign(1) TYPE c,
         option(2) TYPE c,
         low  LIKE <f>,
         high LIKE <f>,
      END OF <rangetab>.

select *
from <database table>
into table <internal table>
where vkorg = p_vkorg
and salesdoc in r_salesdoc
and date in r_date

Hope this helps...

regards,

raam

Read only

Former Member
0 Likes
535

Hi Daniel,

TABLES vbak.

DATA : itab LIKE TABLE OF vbak.

PARAMETERS :
   p_vkorg LIKE vbak-vkorg.
   
SELECT-OPTIONS:
   s_vbeln FOR vbak-vbeln,
   s_erdat FOR vbak-erdat.

  SELECT vbeln
         vkorg
         auart
         erdat
    FROM vbak
    INTO CORRESPONDING FIELDS OF TABLE itab
   WHERE vkorg EQ p_vkorg
     AND vbeln IN s_vbeln
     AND erdat IN s_erdat
     AND ( auart EQ 'ZJE' OR auart EQ 'ZJR' ).

the above query will retrive data as per your condition.

regards,

Brijesh.