cancel
Showing results for 
Search instead for 
Did you mean: 

select statement

Former Member
0 Kudos

Hi,

I have written a select statement like this

SELECT SINGLE vgbel vgpos INTO (l_vgbel,l_vgpos) FROM lips

WHERE vbeln = l_vbeln.

IF SY-SUBRC = 0.

SELECT SINGLE bstkd FROM vbkd INTO l_bstkd

WHERE vbeln = l_vgbel AND

posnr = l_vgpos.

ENDIF.

The first select statement is getting executed.But the second one is showing sy-subrc value 4.What would be the reason?

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi...

It all depends on the declaration of the variables..

Declare the variables as

data l_vgbel type lips-vgbel.

data l_vgpos type lips-vgpos.

SELECT SINGLE vgbel vgpos INTO (l_vgbel,l_vgpos) FROM lips

WHERE vbeln = l_vbeln.

IF SY-SUBRC = 0.

SELECT SINGLE bstkd FROM vbkd INTO l_bstkd

WHERE vbeln = l_vgbel AND

posnr = l_vgpos.

ENDIF.

Regards,

Sai Ramesh

If it is not working then add the below code just before the second select query.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = l_vgbel

IMPORTING

output = l_vgbel.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = l_vgpos

IMPORTING

output = l_vgpos.

What is ur requirement actually ? In general VGBEL in lips contains Purchase order number. VBKD contains only the Sales documents... so it will never give you sy-subrc 0.

Edited by: Sai ramesh on Jan 25, 2008 10:04 AM

Former Member
0 Kudos

Hi,

The requirement is given like this.

For all delivery items on this BOL pick up from LIKP the delivery number and read LIPS for all delivery items shipping on this shipment. Use LIPS-VGBEL and LIPS-VGPOS to access the sales order number and line item and then read VBKD to find the Customer PO numbers BSTKD on this shipment. List all unique customer PO numbers, Do Not repeat them.

Former Member
0 Kudos

Then check this code,,

data l_vbelv type vbfa-vbelv.

data l_posnv type vbfa-posnv.

select single vbelv posnv

from vbfa

into (l_vbelv,l_posnv)

where vbeln = i_vbeln

and posnn = i_posnr

and vbtyp_n = 'J'

and vbtyp_v = 'C'.

  • From the above query u will get the sales order number and item number for a particular deliver item (i_vbeln,i_posnr).

SELECT SINGLE bstkd FROM vbkd INTO l_bstkd

WHERE vbeln = l_vbelv AND

posnr = l_posnv.

Pass these values to VBKD table .. u will get the PO number from BSTKD field.

So for one item in delivery you will get the sales order number and purchase order number.

Repeat the same for all the items... or use ( select ... for all entries ) query to get all the items details at a time.

Regards,

Sai Ramesh

praveen_hannu
Contributor
0 Kudos

use converion routiens if any exists..else data problem.

Former Member
0 Kudos

Hi,

How to use conversion routines?

Former Member
0 Kudos

call the function module CONVERSION_EXIT_ALPHA_INPUT and pass l_vgbel in the exporting and importing parameter then write select statement.

Regards,

Nageswar

ThomasZloch
Active Contributor
0 Kudos

you don't need the conversion routines here. You are selecting the values from the database, they will have the correct format.

Why don't you just try out what I have suggested?

ThomasZloch
Active Contributor
0 Kudos

If I remember correctly...

if the data in VBKD concerns the entire sales order (header level), then VBKD-POSNR will be '000000'.

You should adjust your select to account for this possibility.

Cheers

Thomas

Former Member
0 Kudos

Might me that you dont have values in the table

Or do the conversion exit for l _vgbel

You have conversion exit for vgbel.

Regards,

Nageswar

Edited by: nageswar vattikuti on Jan 24, 2008 8:39 PM

Former Member
0 Kudos

Hi,

Go to Domain of VGBEL field and take the Conversion routine from there ex: ALPHA etc...

Now Call FM CONVERSION_EXIT_ALPHA_INPUT and pass l_vgbel to both import and export parameters.

Now use Converted l_vgbel value for furthur logic.

Regards,

Satish

Former Member
0 Kudos

Here l_vgbel,l_vgpos,l_vbeln,l_bstkd are variables