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

Need help in Select statements

Former Member
0 Likes
449

Hi,

1.I have tried using this code to fetch the values, but it shows runtime error..I need to fetch values from vbak as well as vbap .The condition is when I execute without any values in select options..it should display'please enter atleast one field' also if i enter any invalid entry it should show ' enter a valid entry' and thats what I have tried here.

2. Also I need to check del block or billing block LIFSK , FAKSK = 'x' and always group by document type and print the total of net value.

Plz review the code give me a suitable solution pls..its very urgent..

thanks in advance.


tables : vbak,vbap.

data : begin of itab_vbak occurs 0,
       vbeln(10) type c,
       auart(4) type c,
       netwr(15) type c,
       waerk(5) type c,
       end of itab_vbak.

data : begin of itab_vbap occurs 0,
       zmeng(13) type c,
       zieme(3) type c,
       posnr(6) type c,
       matnr(18) type c,
       end of itab_vbap.

data : it_vbak type table of vbak,
       it_vbap type table of vbap.

select-options : s_vbeln for vbak-vbeln,
                 s_vkorg for vbak-vkorg,
                 s_vtweg for vbak-vtweg,
                 s_spart for vbak-spart.


start-of-selection.

select vbeln auart netwr from vbak into itab_vbak where vbeln in s_vbeln
.

move :  vbak-vbeln to itAB_vbak-vbeln,
        vbak-auart to itab_vbak-auart,
        vbak-netwr to itab_vbak-waerk.

append itab_vbak.

clear itab_vbak.

endselect.


IF   s_vbeln is initial and
     s_vkorg is initial and
     s_vtweg is initial and
     s_spart is initial.

    MESSAGE e000(zam).

  ENDIF.

  IF not s_vbeln[] is initial.

   select * from vbak into table it_vbak where vbeln in s_vbeln.

    IF sy-subrc NE 0.

      MESSAGE e001(zam).

       ENDIF.

   else.


    if not s_vkorg[] is initial.

      select * from vbak into table it_vbak where vkorg in s_vkorg.

         if sy-subrc NE 0.

         message e002(zam).

         endif.

         endif.


     if not s_vtweg[] is initial.

        select * from vbak into table it_vbak where vtweg in s_vtweg.

          if sy-subrc NE 0.

          message e003(zam).

          endif.

          endif.

     if not s_spart[] is initial.

        select * from vbap into table it_vbap where spart in s_spart.

        if sy-subrc NE 0.

        message e004(zam).

        endif.

        endif.

  ENDIF.

  loop at itab_vbak.

write : /25 itab_vbak-vbeln, /30 itab_vbak-auart,/40 itab_vbak-netwr.

endloop.

Edited by: Alvaro Tejada Galindo on Feb 7, 2008 8:46 AM

3 REPLIES 3
Read only

Former Member
0 Likes
423

hi,

chk this....



tables : vbak,vbap.

data : begin of itab_vbak occurs 0,
vbeln like vbak-vbeln,
auart like vbak-auart,
netwr like vbak-netwr,
waerk like vbak-waerk,
end of itab_vbak.

data : begin of itab_vbap occurs 0,
zmeng(13) type c,
zieme(3) type c,
posnr(6) type c,
matnr(18) type c,
end of itab_vbap.

data : it_vbak type table of vbak,
it_vbap type table of vbap.

select-options : s_vbeln for vbak-vbeln,
s_vkorg for vbak-vkorg,
s_vtweg for vbak-vtweg,
s_spart for vbak-spart.

at selection-screen.

IF s_vbeln is initial and
s_vkorg is initial and
s_vtweg is initial and
s_spart is initial.

MESSAGE e000(zam).

ENDIF.


IF not s_vbeln[] is initial.

select * from vbak into table it_vbak where vbeln in s_vbeln.

IF sy-subrc NE 0.

MESSAGE e001(zam).

ENDIF.

else.

if not s_vkorg[] is initial.

select * from vbak into table it_vbak where vkorg in s_vkorg.

if sy-subrc NE 0.

message e002(zam).

endif.

endif.

if not s_vtweg[] is initial.

select * from vbak into table it_vbak where vtweg in s_vtweg.

if sy-subrc NE 0.

message e003(zam).

endif.

endif.

if not s_spart[] is initial.

select * from vbap into table it_vbap where spart in s_spart.

if sy-subrc NE 0.

message e004(zam).

endif.

endif.

ENDIF.


start-of-selection.

select vbeln auart netwr waerk from vbak
       into table itab_vbak
       where vbeln in s_vbeln.



*move : vbak-vbeln to itAB_vbak-vbeln,
*vbak-auart to itab_vbak-auart,
*vbak-netwr to itab_vbak-waerk.
*
*append itab_vbak.
*
*clear itab_vbak.
*

loop at itab_vbak.

write : /25 itab_vbak-vbeln, 30 itab_vbak-auart, 40 itab_vbak-netwr.

endloop.

do reward if it helps,

priya.

Edited by: Priya Parvathi Jammalamadaka on Feb 7, 2008 2:59 PM

Read only

Former Member
0 Likes
423

Change the data type of netwr from character to NETWR. It will work.

Ex:

data : begin of itab_vbak occurs 0,

vbeln(10) type c,

auart(4) type c,

netwr type NETWR,

waerk(5) type c,

end of itab_vbak.

Read only

Former Member
0 Likes
423

Hi,

Need to use AT SELECTION-SCREEN ON Field for individual fied to check for the valid entry.

You can use AT SELECTION-SCREEN event to check and raise error message if all the vlauees are empty.

Later you need to use START-OF_SELECTION.

KindRegards,

khader.