‎2007 Sep 19 10:43 PM
Hi every one,
my requirement is as below.....
SELECT lfsta
fksaa
gbsta FROM vbup INTO TABLE t_vbup
WHERE vbeln = vbap-vbeln AND
posnr = vbap-posnr AND
lfsta IN s_status AND
gbsta IN s_bilst AND
fksaa IN s_bilst.
IF sy-subrc NE 0 .
SELECT lfsta
fksaa
gbsta FROM vbup INTO TABLE t_vbup
WHERE vbeln = vbap-vbeln AND
posnr = vbap-posnr AND
lfsta IN s_status AND
fksaa IN s_bilst.
ELSEIF sy-subrc NE 0.
SELECT lfsta
fksaa
gbsta FROM vbup INTO TABLE t_vbup
WHERE vbeln = vbap-vbeln AND
posnr = vbap-posnr AND
lfsta IN s_status AND
gbsta IN s_bilst.
ENDIF.
when the first query fails it should check in second and then if it fails then it should check in third.....all the conditions for first to entries are satisfying and my logic is working gud.....but there is a problem in third query if never populates into table......but when i take this query out of the if and elseif condition it works properly but my requirement fails for the given scenario.....how can i make this third qurey work properly without effecting my scenario requirement.....
‎2007 Sep 19 10:47 PM
Try this
SELECT lfsta
fksaa
gbsta FROM vbup INTO TABLE t_vbup
WHERE vbeln = vbap-vbeln AND
posnr = vbap-posnr AND
lfsta IN s_status AND
gbsta IN s_bilst AND
fksaa IN s_bilst.
IF sy-subrc NE 0 .
SELECT lfsta
fksaa
gbsta FROM vbup INTO TABLE t_vbup
WHERE vbeln = vbap-vbeln AND
posnr = vbap-posnr AND
lfsta IN s_status AND
fksaa IN s_bilst.
IF sy-subrc NE 0.
SELECT lfsta
fksaa
gbsta FROM vbup INTO TABLE t_vbup
WHERE vbeln = vbap-vbeln AND
posnr = vbap-posnr AND
lfsta IN s_status AND
gbsta IN s_bilst.
ENDIF.
endif.
‎2007 Sep 19 10:47 PM
Change the elseif to an if and add an endif:
SELECT lfsta fksaa gbsta
FROM vbup INTO TABLE t_vbup
WHERE vbeln = vbap-vbeln AND
posnr = vbap-posnr AND
lfsta IN s_status AND
gbsta IN s_bilst AND
fksaa IN s_bilst.
IF sy-subrc NE 0 .
SELECT lfsta
fksaa
gbsta FROM vbup INTO TABLE t_vbup
WHERE vbeln = vbap-vbeln AND
posnr = vbap-posnr AND
lfsta IN s_status AND
fksaa IN s_bilst.
IF sy-subrc NE 0. "<========
SELECT lfsta
fksaa
gbsta FROM vbup INTO TABLE t_vbup
WHERE vbeln = vbap-vbeln AND
posnr = vbap-posnr AND
lfsta IN s_status AND
gbsta IN s_bilst.
ENDIF.
ENDIF. "<=======Rob
‎2007 Sep 19 11:19 PM
Thanks Rob and Sams,
I've already tried with this below thing but the problem is regarding my scenario...l'l have to tell u this for getting my scenario.......
l have my vbup table with fksaa and gbsta field active.....
lets take a example....from vbup for better understanding
<b><u>vbeln posnr fksaa gbsta</u></b>
30001 10 B B
30001 20 A A
30001 30 B B
30001 40 C B
30002 10 --- B
30003 20 -
C
Now when i give some entry in s_bilst in selection screen field for example A to B then as you know the very first select query gets B and A related entries into the table...and displays the entries like below
30001 10 B B
30001 20 A A
30001 30 B B
and for 4th entry the third query triggers and displays the 4th entry too after the third entry.....like
30001 40 B
This is what i dont want because i'm giving only A to B range in the selection screen(which is common for both fksaa and gbsta and i'm restricted to have only one selection screen for both the fields) and it shud not show the four entries instead it should show only three entries.......and when i give only C in the entry the 4th entry is displaying properly for ur said logic.....every thing works fine but apart from the above problem with ur if conditions.......
And for my logic it wont be displaying the fourth entry it instead displays the 3 enties when A to B range is given and only single entry when C is given in the selection screen.......but the only problem is with the last entry where fksaa field is empty this is not triggering the last select query and not ...........for my if and elseif conditions....i already tried with ur if conditions but no solution how should i solve this without effecting my requirement.....
‎2007 Sep 20 5:33 AM
Hi
Try this
SELECT lfsta
fksaa
gbsta FROM vbup INTO TABLE t_vbup
WHERE vbeln = vbap-vbeln AND
posnr = vbap-posnr AND
(
lfsta IN s_status or
gbsta IN s_bilst or
fksaa IN s_bilst ).
thanks
Dharmishta