2007 Apr 06 1:04 AM
Hi,
I am trying the code to pass an internal table with header line to a form .
data: dtab type standard table of itab with header line.
data: dtab1 type standard table of itab1 with header line.
PERFORM lookup USING dtab
CHANGING dtab1.
form lookup using p_dtab type any
changing p_dtab1 type any.
loop at p_dtab.
read table p_dtab1
with key a = p_dtab-a.
move-corresponding p_dtab1 to p_dtab.
endloop.
endform.
What am i doing wrong here ??. It keeps complaining p_dtab not defined in data statement.
thanks
amit
2007 Apr 06 4:05 AM
Hi,
Check this code. Let me know if you have any question.
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
DATA: BEGIN OF itab OCCURS 0,
a TYPE c,
END OF itab.
DATA: BEGIN OF itab1 OCCURS 0,
a TYPE c,
END OF itab1.
DATA: dtab LIKE itab OCCURS 0 WITH HEADER LINE.
DATA: dtab1 LIKE itab1 OCCURS 0 WITH HEADER LINE.
PERFORM lookup TABLES dtab
dtab1.
*---------------------------------------------------------------------*
* FORM lookup *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> P_DTAB *
* --> P_DTAB1 *
*---------------------------------------------------------------------*
FORM lookup TABLES p_dtab STRUCTURE itab
p_dtab1 STRUCTURE itab1.
LOOP AT p_dtab.
READ TABLE p_dtab1 WITH KEY a = p_dtab-a.
MOVE-CORRESPONDING p_dtab1 TO p_dtab.
ENDLOOP.
ENDFORM.
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*Regards,
RS
2007 Apr 06 1:16 AM
Amit,
Instead of looping at p_dtab use loop on dtab only.
Regards,
Amey
2007 Apr 06 2:56 AM
Amey,
Thanks but why am i not able to use p_tab. Am i missing something.If i needed to use dtab i would not even need a subroutine.
thanks
amit
2007 Apr 06 3:32 AM
hi amit,
defined the form like this.
FORM LOOKUP USING P_DTAB STRUCTURE ITAB
CHANGING P_DTAB1 STRUCTURE ITAB1.
.....
ENDFORM .
try this ,and i think you will get the result you want
regards.
2007 Apr 06 4:05 AM
Hi,
Check this code. Let me know if you have any question.
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
DATA: BEGIN OF itab OCCURS 0,
a TYPE c,
END OF itab.
DATA: BEGIN OF itab1 OCCURS 0,
a TYPE c,
END OF itab1.
DATA: dtab LIKE itab OCCURS 0 WITH HEADER LINE.
DATA: dtab1 LIKE itab1 OCCURS 0 WITH HEADER LINE.
PERFORM lookup TABLES dtab
dtab1.
*---------------------------------------------------------------------*
* FORM lookup *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> P_DTAB *
* --> P_DTAB1 *
*---------------------------------------------------------------------*
FORM lookup TABLES p_dtab STRUCTURE itab
p_dtab1 STRUCTURE itab1.
LOOP AT p_dtab.
READ TABLE p_dtab1 WITH KEY a = p_dtab-a.
MOVE-CORRESPONDING p_dtab1 TO p_dtab.
ENDLOOP.
ENDFORM.
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*Regards,
RS
2007 Apr 06 4:10 AM
use TABLES clause and in the subroutine do the operation as mentioned by RS.
rgds
Nishant
2007 Apr 06 4:26 AM
Hi..,
It gives syntax error ...like p_dtab is not an internal table...
Because till the runtime , it doesn't the type of the Object p_dtab. In the runtime onli it gets the properties of the DTAB , then onli u can loop at this p_dtab....
So in syntax checking it doesn,t know that it is a table... so it is not allowing the loop at !! that is your problem !!
Hope u understood the problem..
Try this.. this solves your problem !!!
<b>PERFORM lookup USING dtab
CHANGING dtab1.
form lookup using p_dtab type dtab <u><i>** here if it doesnt work , write STRUCTURE instead of TYPE )</i></u>
changing p_dtab1 type dtab1. <u><i>** here also)</i></u>
loop at p_dtab.
read table p_dtab1
with key a = p_dtab-a.
move-corresponding p_dtab1 to p_dtab.
endloop.
endform.</b>
Or u can use the Tables statement also.. as one of the friend suggested !! But the problem in your coding is this !!
regards,
sai ramesh