Application Development 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: 

regarding filling of the internal table.

Former Member
0 Kudos

Hi Experts,

I'm using a custom table ztest in a badi.

now ,

when I execute this badi the xmseg internal table without header line  fills up .

so I looped at xmseg into wa_xmseg so I can use the following condition.

select * from ztest into wa_test where werks = wa_xmseg-werks and value = wa_xmseg-mtart.

endselect.

when I run in debugging mode value of sy-subrc = 4.

So I tried using read and loop statement but a error message pops up saying that ztest is not defined in the data .

so what has to be done.

regards, Suhas.

8 REPLIES 8

karun_prabhu
Active Contributor
0 Kudos

Try declaring the Z table using the statement TABLES : ztest.

0 Kudos

Hi Suhas,

Can you please paste the exact message.

And you cannot use Tables statement in OO

FredericGirod
Active Contributor
0 Kudos

Hi,

using BADI means that you are in an Oo context, so please try to code in the Oo way.

SELECT .... 

              into table wa_test

               from ztest

              where.

loop at wa_test into is_test.

...

endloop.

where wa_test is an internal table without header line and is_test is a structure.

regards

Fred

Former Member
0 Kudos

Hi,

All applies to OO Context..

1. You can declare workarea like...

    DATA: ztest TYPE ztest.

    in above statement first ztest is workarea name and second ztest is z-table.

2. or if you want to declare internal table.. you can do like

    DATA: it_ztest TYPE TABLE OF ztest.

3. Or if want declare workarea for it_ztest then you do like..

     DATA: l_ztest LIKE line of it_zmm.

Regards

Tejas

Former Member
0 Kudos

Hi,

SELECT SINGLE *

                FROM Ztest

                INTO  wa_test

               WHERE <condition>.

  where wa_test is a structure or work area.

regards

Praveen

Former Member
0 Kudos

Hi Suhas,

Please post the code because from my experience if the Z table is correctly activated then you should be able to use it directly in queries because entire Data Dictionary's objects are in scope of the BADIs.

BR,

Ankit.

0 Kudos

Hi Suhas,

As I get from your query (Mention below)

select * from ztest into wa_test where werks = wa_xmseg-werks and value = wa_xmseg-mtart.

endselect.

U have not written append inside the select endselect hence you are trying to get the last record in the work area from your Z table and depending upon the Z table key (Considering if WERKS and VALUE is not primary key) there can we multiple if WERKS and VALUE does not make the primary key hence at last you get SY-SUBRC equal to 4 and your work area is blank .

If I understood your query correctly then below mention code will be helpful for you

1. create a  standard internal table of ZTEST type

2. Create a work area of ZTEST type

Put a query of ZTEST by passing desired value in WERKS and VALUE field(refer below mention query)

Refresh IT_ZTEST. (Considerind IT_ZTEST is your internal table)

select * from ZTEST into table IT_ZTEST

where werks = wa_xmseg-werks and value = wa_xmseg-mtart.

Now IT_ZTEST have all the record

LOOP IT_ZTEST into WA_ZTEST(Considering WA_ZTEST is your work area).

ENDLOOP.

Note: Please try to avoid select endselect as much as possible use select * into table or for all entries as select endselect is obselete

Regards,

Deepak Jain.

former_member420878
Active Participant
0 Kudos

Hi Suhas,

Can you please post the exact error.

otherwise according to my understanding,

1. Please check ZTEST table in SE16 with the given criteria.

2. Avoid use of select endselect statements, better to go for "Select Single" or "select * into table".

3. Avoid using selects inside loops, instead try to use read statements.

Thanks