‎2008 May 09 3:12 PM
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
‎2008 May 09 3:40 PM
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
‎2008 May 09 3:44 PM
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.
‎2008 May 09 3:56 PM
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.
‎2008 May 09 4:02 PM
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
‎2008 May 09 4:14 PM
doesn't work. says unknown column name x-whno not determined until runtime cannot specify a field list.
‎2008 May 09 4:39 PM
Use:
SELECT whno, cnter FROM x INTO CORRESPONDING FIELDS OF TABLE itab1
WHERE LGTYP = z-WSTYP and whno = z-whno.
‎2008 May 09 4:40 PM
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
‎2008 May 09 4:41 PM
The error i got was aftet removing the comma. doesn't help.
‎2008 May 09 5:38 PM
‎2008 May 09 5:45 PM
for the method Z(internal structure) is the changing parameter
‎2008 May 09 8:31 PM
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.
‎2008 May 09 8:36 PM
You are missing a period '.' after loop at L_TAB1
loop at L_TAB1.
‎2008 May 10 6:33 AM
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
‎2008 May 09 3:47 PM
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
‎2008 May 10 12:42 AM
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
‎2008 May 10 6:37 AM
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