2013 Apr 04 9:11 PM
Hi Experts,
It is abit hard to explain what I need here.
But I try to explain as much as I can.
i m using this structure
******* Declaration Part Starts ********
DATA: BEGIN OF XVBPA OCCURS 0. "#EC ENHOK
INCLUDE STRUCTURE VBPAVB.
DATA: END OF XVBPA.
DATA: w_kunnr TYPE vbpa-kunnr.
******* Declaration Part Ends ********
.
.
.
and using this SELECT query
SELECT SINGLE kunnr FROM xvbpa INTO w_kunnr WHERE parvw eq lc_ag.
it gives error...
Please let me know what shold i used or shall use any other table to fetch like READ TABLE statement???
2013 Apr 04 11:19 PM
Hi Nikita,
When you declare XVBPA you're in fact defining an internal table that is an area where, for your purposes, you'll keep your data (in case retrieved from database through your SELECT). But it doesn't represent the transparent table itself what would be, as Chamo mentioned above, VBPA.
But according to piece of code you've shared that XVBPA internal table wouldn't be really necessary once in fact you're just retrieving the customer number (KUNNR) from your sales order partners (VBPA). So the way you're doing by fetching data into variable W_KUNNR is pretty much correct (but I'd suggest you to add sales order number and item, VBELN and POSNR respectively, to your selection other it will simply bring first entry found in VBPA (that could be from any sales order else yours).
Regarding your question about READ statement it's used for to read data from your XVBPA internal table mentioned above. So your program would look like:
SELECT SINGLE kunnr FROM vbpa INTO w_kunnr WHERE vbeln EQ lv_vbeln
AND posnr EQ lv_posnr
AND parvw EQ lc_ag.
Please let me know if you have any doubt.
Regards,
Edgar
2013 Apr 04 9:19 PM
Hi,
In this case XVBPA is just a internal table and it is not a database talbe. Select statemtns work with Database tables. So please change it to VBPA and then check the results.
Regards
Vinay
2013 Apr 04 9:39 PM
Hi,
xvbpa is your internal table....
this is your select....
SELECT SINGLE kunnr FROM xvbpa INTO w_kunnr WHERE parvw eq lc_ag.
xvbpa isn't a db table... for this there's a syntax error.
Regards
Ivan
2013 Apr 04 10:37 PM
Hi nikita
I think you does use incorrect table in your query.
The correct table is vbpa.
2013 Apr 04 10:52 PM
Hi Chamo,
Basically xvbpa is a structure.
i dint use vbpa. as i have to copare and want to select kunnr from xvbpa.
any suggestions???
2013 Apr 04 11:19 PM
Hi Nikita,
When you declare XVBPA you're in fact defining an internal table that is an area where, for your purposes, you'll keep your data (in case retrieved from database through your SELECT). But it doesn't represent the transparent table itself what would be, as Chamo mentioned above, VBPA.
But according to piece of code you've shared that XVBPA internal table wouldn't be really necessary once in fact you're just retrieving the customer number (KUNNR) from your sales order partners (VBPA). So the way you're doing by fetching data into variable W_KUNNR is pretty much correct (but I'd suggest you to add sales order number and item, VBELN and POSNR respectively, to your selection other it will simply bring first entry found in VBPA (that could be from any sales order else yours).
Regarding your question about READ statement it's used for to read data from your XVBPA internal table mentioned above. So your program would look like:
SELECT SINGLE kunnr FROM vbpa INTO w_kunnr WHERE vbeln EQ lv_vbeln
AND posnr EQ lv_posnr
AND parvw EQ lc_ag.
Please let me know if you have any doubt.
Regards,
Edgar
2013 Apr 05 12:42 AM
Hi Edgar,
xvbpa is internal table of type Structure .
DATA: BEGIN OF XVBPA OCCURS 0.
INCLUDE STRUCTURE VBPAVB.
DATA: END OF XVBPA.
In my program i want to compare Kunnr with some constant value "AG" which i have taken in constant declare as lc_ag.
DATA: lc_ag(2) TYPE c VALUE 'AG'.
But when i m using Select Query like:-
READ TABLE int_xvbpa INTO ws_int_xvbpa WITH TABLE KEY kunnr = lc_ag.
it gives error mention in the attached image ..
Thanks....
2013 Apr 05 5:31 AM
2013 Apr 05 5:39 AM
Without all the code, some guessing exercise
Think your READ statement should be:
READ TABLE xvbpa INTO ws_int_xvbpa WITH KEY kunnr = lc_ag.
Ensure XVBPA is visible to your routine (declared in it or at global level).
2013 Apr 05 5:44 AM
Hi Nikita,
Just going to change your declaration around a bit.
If there isn't anymore additional fields within your internal table XVBPA. Can you declare it as:
DATA: XVBPA type standard table of VBPAVB,
lw_XVBPA type VBPAVB.
To declare constants:
Constants: lc_ag(2) type c value 'AG'.
And last but not least, I assume you want to select everything that have a prefix or post fix of AG.
Loop at XVBPA into lw_XVBPA where kunnr cs lc_ag.
......
.....
.....
Endloop.
Best regards,
Brian
2013 Apr 05 5:52 AM
Hi Thung,
Your code is quite right but I started to think it's about a user-exit and she needs to go straight to entry from XVBPA where KUNNR is equal AG. In this way a LOOP wouldn't be necessary.
Regards,
Edgar
2013 Apr 05 6:13 AM
Hi Edgar,
I'm not an expert in Logistic, hence I am not sure if this is a user exit, so correct me if I am wrong, KUNNR is a customer number that contains 8 characters. Her constant is a 2 character field, hence I sort of thinking she is trying to group up all customer that have a prefix code of AG. Hence where the loop kicks in.
If she just want 1 record, then ya...read will be a better option.
Another thing I picked up from her reply as well, the error is with XVBPA, but when you look how she code the read statement:
READ TABLE int_xvbpa INTO ws_int_xvbpa WITH TABLE KEY kunnr = lc_ag.
So there is definately something wrong with the code that don't match the print screen. Can't really help much without seeing the whole code though.
Best regards,
Brian
2013 Apr 05 6:17 AM
Yep, it's indeed another good point (noticed that but didn't care about, my mistake...), customer numbers doesn't look like that AG that actually I started to guess is the partner type.
2013 Apr 05 8:20 AM
Hey... Thanks Edgar... Problem is solved.
I have used same Read statement it's Working...
Thanks Vinay you are rite... we can used select statement with DB Table.
Thanks Thung , Ivan and Chamo ....