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

Code in BADI method

Former Member
0 Likes
1,716

Hi Experts,

I am trying to implemet a BADI and below is the code in the implementation method.

could you please let me know what is wrong in this code?

i am getting errors like Tables cannot be used in BADIs etc....could you correct me.

Appreciate your help

METHOD xyz~t.

tables : x,y.

types: begin of l_tab1,

whno type x-whno,

cnter type x-cnter,

end of l_tab1.

types: begin of l_tab2,

whno type y-whno,

trtype type y-trtype,

end of l_tab2.

DATA: ITAB1 type table of l_tab1.

DATA: ITAB2 TYPE TABLE OF l_tab2.

SELECT x-whno, x-cnter FROM x INTO CORRESPONDING FIELDS OF TABLE itab1

WHERE x-LGTYP = z-WSTYP and z-whno = z-whno.

IF sy-subrc EQ 0.

REFRESH itab2.

SELECT whno, TRTYPe FROM y

INTO CORRESPONDING FIELDS OF TABLE itab2

FOR ALL ENTRIES IN itab1

WHERE y-cnter = itab1-cnter and y-whno = itab1-whno.

IF sy-subrc EQ 0.

z-mv = 0.

ENDIF.

ENDIF.

ENDMETHOD.

thanks

16 REPLIES 16
Read only

Former Member
0 Likes
1,649

Hi,

You have defined

Tables : x, y.

You cannot define the tables in the BADi.

If you are using this for workare then you can create the workarea using statement,

data : wa_x type x.

Even you can't use TYPE.

regards,

mahantesh

Edited by: Mahantesh Patil on May 9, 2008 4:41 PM

Read only

Former Member
0 Likes
1,649

Hi,

Instead of writing the code in the method write the code in the function moduel by passing the variable and do what ever you need and get the expected data in the tables or iimporting parameters.

Thanks,

NN.

Read only

0 Likes
1,649

i am new to badi i don't know how to accomplish the same. Even if i remove tables statement it doesn't work.

it gives me another error. comma without preceeding colon(after select?). help me with this method.

will appreciate ur help.

thanks.

Read only

0 Likes
1,649

Hi,

SELECT x-whno, x-cnter FROM x INTO CORRESPONDING FIELDS OF TABLE itab1

WHERE x-LGTYP = z-WSTYP and z-whno = z-whno.

Please remove the comma from the above statement.

regards,

mahantesh

Read only

0 Likes
1,649

doesn't work. says unknown column name x-whno not determined until runtime cannot specify a field list.

Read only

0 Likes
1,649

Use:

SELECT whno, cnter FROM x INTO CORRESPONDING FIELDS OF TABLE itab1

WHERE LGTYP = z-WSTYP and whno = z-whno.

Read only

0 Likes
1,649

SELECT whno cnter FROM x INTO CORRESPONDING FIELDS OF TABLE itab1

WHERE LGTYP = z-WSTYP and whno = z-whno.

pasted the comma in the last post...remove comma

Read only

0 Likes
1,649

The error i got was aftet removing the comma. doesn't help.

Read only

0 Likes
1,649

Hi,

what this variable z- is indicating.

regards,

mahantesh

Read only

0 Likes
1,649

for the method Z(internal structure) is the changing parameter

Read only

0 Likes
1,649

THE BELOW code does work except for when i try to loop through the internal table it says loop should be used with into or transporation etc.... can anyone tell me how to use this. will appreciate ur help.

*----


TYPES: BEGIN OF LT_TAB1,

LGNUM TYPE X-LGNUM,

WORKSTATION TYPE X-WORKSTATION,

WRKSTTYP TYPE X-WRKSTTYP,

END OF lT_tab1.

TYPES: BEGIN OF LT_TAB2,

LGNUM TYPE Y-LGNUM,

TRTYP TYPE Y-TRTYP,

END OF lT_tab2.

data: L_TAB1 type standard table oF LT_TAB1 initial size 0.

data: L_TAB2 type standard table of LT_TAB2 initial size 0.

SELECT FLGNUM FWORKSTATION F~WRKSTTYP INTO CORRESPONDING FIELDS OF TABLE L_TAB1

FROM X AS F WHERE FLGNUM = Z-LGNUM AND FLGTYP = Z-WSTYP.

IF SY-SUBRC <> 0.

WRITE: / 'NO MATCHING RECORDS FOUND'.

ELSE.

WRITE:/ 'workcenter'.

loop at L_TAB1

WRITE:/ L_TAB1-LGNUM,L_TAB1-WORKSTTYP,L_TAB1-WORKSTATION.

ENDLOOP.

ENDIF.

Read only

0 Likes
1,649

You are missing a period '.' after loop at L_TAB1

loop at L_TAB1.

Read only

0 Likes
1,649

Hello Bindu,

When you declare a table like

DATA: itab type table type_structure.

you don't have a Header-line!

You have to do the following for a proper LOOP run:

DATA: itab type table type_structure,
          wa_itab type type_structure.
...
...
LOOP at itab into wa_itab.
* working with the wa_itab fields
...
...
ENDLOOP.

Have success,

Heinz

Read only

matt
Active Contributor
0 Likes
1,649

The only error seems to be your TABLES statement. You can just remove it and your program should work.

The TABLES statement just defines a work area. It used to be necessary, if I remember correctly, in order to select from db tables, but this is no longer the case.

matt

Read only

Former Member
0 Likes
1,649

Hi Bindu,

You got already a lot of smart information. What's about you TYPES statement? When your tables: x, y. are transparent tables, your TYPES declaration has to look like:

TYPES: begin of l_tab1,
               whno LIKE x-whno,
               cnter LIKE x-cnter,
             end of l_tab1.

The same for l_tab2.

Check it out,

Heinz

Read only

Former Member
0 Likes
1,649

Hello Bindu,

When you declare a table like

DATA: itab type table type_structure.

you don't have a Header-line!

You have to do the following for a proper LOOP run:

DATA: itab type table type_structure,
          wa_itab type type_structure.
...
...
LOOP at itab into wa_itab.
* working with the wa_itab fields
...
...
ENDLOOP.

Have success,

Heinz