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 to a form

Former Member
0 Likes
760

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
716

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

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

6 REPLIES 6
Read only

Former Member
0 Likes
716

Amit,

Instead of looping at p_dtab use loop on dtab only.

Regards,

Amey

Read only

0 Likes
716

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

Read only

Former Member
0 Likes
716

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.

Read only

Former Member
0 Likes
717

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

Read only

Former Member
0 Likes
716

use TABLES clause and in the subroutine do the operation as mentioned by RS.

rgds

Nishant

Read only

Former Member
0 Likes
716

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