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

Internal table Usage problem in ABAP ...

Former Member
0 Likes
3,126

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???

1 ACCEPTED SOLUTION
Read only

edgar_nagasaki
Contributor
0 Likes
2,849

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

13 REPLIES 13
Read only

former_member210730
Participant
0 Likes
2,849

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

Read only

Former Member
0 Likes
2,849

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

Read only

Former Member
0 Likes
2,849

Hi nikita

I think you does use incorrect table in your query.

The correct table is vbpa.

Read only

Former Member
0 Likes
2,849

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???

Read only

edgar_nagasaki
Contributor
0 Likes
2,850

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

Read only

0 Likes
2,849

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....

Read only

0 Likes
2,849

Hi Nikita,

Could you share all your code over here?

Edgar

Read only

0 Likes
2,849

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).

Read only

0 Likes
2,849

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

Read only

0 Likes
2,849

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

Read only

0 Likes
2,849

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

Read only

0 Likes
2,849

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.

Read only

Former Member
0 Likes
2,849

Hey...   Thanks Edgar... Problem is solved.

I have used same Read statement it's Working...

Thanks Vinay

Thanks Thung , Ivan and  Chamo  ....