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

qeury in PAI module : error

Former Member
0 Likes
1,132

Hi experts

I have used this query in my PAI module.

I have value on the field zrecpt-vbeln

first query is working, but second query is not working,

it returns the value sy-subrc = 4.

Can anyone help me, whats the mistake with second query and how to correct.

CHAIN .

FIELD : zrecpt-zrno.

MODULE vali_zrno ON CHAIN-INPUT.

ENDCHAIN.

MODULE vali_zrno INPUT.

if zrecpt-zrno is not initial.

select single * from zrecpt

where zrno = zrecpt-zrno.

endif.

select single vbeln kunnr from vbak

into (vbak-vbeln , vbak-kunnr)

where vbeln = zrecpt-vbeln.

ENDMODULE.

Thanks in advance.

Regards

Rajaram

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,107

Hi Rajaram ,

Please check the value of zrecpt-vbeln , it should be of length 10 , if it is not of length 10 then predeed it with 0 .

This can be done using the UNPACK command , use the follwing statement before the select statement

<b>UNPACK zrecpt-vbeln TO zrecpt-vbeln.</b>

Regards

Arun

Hi experts

I have used this query in my PAI module.

I have value on the field zrecpt-vbeln

first query is working, but second query is not working,

it returns the value sy-subrc = 4.

Can anyone help me, whats the mistake with second query and how to correct.

CHAIN .

FIELD : zrecpt-zrno.

MODULE vali_zrno ON CHAIN-INPUT.

ENDCHAIN.

MODULE vali_zrno INPUT.

if zrecpt-zrno is not initial.

select single * from zrecpt

where zrno = zrecpt-zrno.

endif.

select single vbeln kunnr from vbak

into (vbak-vbeln , vbak-kunnr)

where vbeln = zrecpt-vbeln.

ENDMODULE.

Thanks in advance.

Regards

Rajaram

8 REPLIES 8
Read only

Former Member
0 Likes
1,107

Hi raja Ram,

select single vbeln kunnr from vbak

into (vbak-vbeln , vbak-kunnr)

where vbeln = zrecpt-vbeln.

ENDMODULE

Here <b>vbak-vbeln vbak-kunnr</b> - you have to Internal table field names.

Thanks,

Reward If Helpful.

Read only

Former Member
0 Likes
1,107

try to save the data of variable zrecpt-vbeln in one global variable and then try for query,,,ok

reward points if useful.....

Read only

Former Member
0 Likes
1,107

CHAIN .

FIELD : zrecpt-zrno.

MODULE vali_zrno ON CHAIN-INPUT.

ENDCHAIN.

MODULE vali_zrno INPUT.

DATA : WA_ZRECPT LIKE ZRECPT.

select single * from zrecpt INTO WA_ZRECPT

where zrno = zrecpt-zrno.

endif.

endif.

select single vbeln kunnr from vbak

into (vbak-vbeln , vbak-kunnr)

where vbeln = WA_zrecpt-vbeln.

ENDMODULE.

REWARD IF USEFUL.

aMIT sINGLA

Read only

Former Member
0 Likes
1,107

Check my comment below -

MODULE vali_zrno INPUT.

if zrecpt-zrno is not initial.

select single * from zrecpt

where zrno = zrecpt-zrno.

<b>Here check if the select is working fine by checking SY-SUBRC</b>

<b>if sy-subrc eq 0.</b>

select single vbeln kunnr from vbak

into (vbak-vbeln , vbak-kunnr)

where vbeln = zrecpt-vbeln.

<b>Check in VBAK if there is an record with VBELN = ZRECPT-VBELN.</b>

endif.

endif.

ENDMODULE.

You can keep a break point in the code and check if SELECTs are working fine.

BTW is ZRECPT-VBELN is present on the screen too?

Read only

Former Member
0 Likes
1,108

Hi Rajaram ,

Please check the value of zrecpt-vbeln , it should be of length 10 , if it is not of length 10 then predeed it with 0 .

This can be done using the UNPACK command , use the follwing statement before the select statement

<b>UNPACK zrecpt-vbeln TO zrecpt-vbeln.</b>

Regards

Arun

Read only

0 Likes
1,107

Its really great yar, working fine by your suggestion.

whats the use of UNPACK command,

why we go for this, even length of both fields are equal.

Thanks for everyone who have helped me.

Regards

Rajaram

Read only

0 Likes
1,107

Hi Rajaram ,

The purpose of Unpack command is to preced a varaible with zeros , please see the help of it for more info.

If you select the data form the database and assign it to the varaible it will work fine , but i feel you are getting it as a user input , since the user enteres it without 0's so the same value is passed on to the varaible , the legth of the varaible has nothing to do with it , that is one reason why we have the concepr of conversion exits , which converts data into input and output formats.

Regards

Arun

Read only

0 Likes
1,107

Hi Raja Ram,

If ur variable is of type C and size 10 and the value of that variable is 3456.

when u display it it will come by 3456.

but if u use unpack var to var.

then the value will be 0000003456.

Thanks,

Reward If Helpful.