08-23-2005 10:12 AM
Hi,
In my requirement,I am having two performs.Both are calling the same form.Perform is passing one internal table.But the structure of the internal tables in two performs are different.But I want both the perform should call the same form.
Code:
data itab1 type standard table of mara.
data itab2 type standard table of makt.
select * from mara into table itab1.
select * from makt into table itab2.
perform display tables itab1.
perform display tables itab2.
How the form should be?
Thanks in Advance.
Regards,
J.Jayanthi
08-23-2005 10:21 AM
use
perform display using itab1.
perform display using itab1.
and....
form display using itab type any table.
endform.
Christian
08-23-2005 10:18 AM
If modularisation is the aim, then you can do the same thing with Function Modules, without declaring the type of the internal table in Tables in the interface of the Function Module.
However there has to be some way to recognise the structure of the table.
If you recognise the REUSE_ALV_LIST_DISPLAY and similar function modules, they use the field catalog to recognise the structure of the internal table , then dynamically create the internal table and list the values in ALV
Regards,
Subramanian V.
08-23-2005 10:21 AM
use
perform display using itab1.
perform display using itab1.
and....
form display using itab type any table.
endform.
Christian
08-23-2005 10:26 AM
I think what Christian mentioned will work but with the following correction.
perform display using itab1[].
perform display using itab1[].
08-23-2005 10:30 AM
no need for [].
what christian and kathirvel has mentioned should work.
Regards
Raja
08-23-2005 10:36 AM
It does work if defined without header line.
As a matter of fact I always neglect that because I haven't created a table with header line for years.
Christian
08-23-2005 10:42 AM
Hi,
try that:
perform display tables itab1.
perform display tables itab2.
form display tables itab type table.
...
endform.
Andreas
08-23-2005 10:57 AM
Hi All,
Thanks a lot for the response.
But I want to access the fields of the internal table inside the form.For example,I need to write all the field values of internal table inside the form.How is it possible?
data itab1 type standard table of mara .
data itab2 type standard table of makt .
data ln type i.
select * from mara into table itab1.
perform display tables itab1 .
select * from makt into table itab2.
perform display tables itab2.
form display tables itab type table.
data wa type ???
loop at itab into wa.
write ????
endloop.
endform. " display
08-23-2005 11:08 AM
Something like following should work:
Tables is kind of outdated I do not like it - and there is no benefit in using it.
form display using itab type any table.
<field-symbols>: <line> type any,
<l_field> type field.
data: l_i type i.
loop at itab assigning <line>.
l_i = 1.
do.
assign component l_i of structure <line> to <l_field>.
if not sy-subrc is initial. exit. endif.
write: <l_field>.
l_i = l_i + 1.
enddo.
new-line.
endloop.
endform. " display
CHristian
08-23-2005 11:12 AM
Hi,
My code is almost as Christian's.
FORM DEMO USING mytab TYPE ANY TABLE.
field-symbols: <fs> type any,
<fs1> type any.
loop at mytab assigning <fs>.
do.
ASSIGN COMPONENT sy-index OF STRUCTURE <fs> TO <fs1>.
write <fs1>.
if sy-subrc ne 0.
exit.
endif.
enddo.
new-line.
endloop.
endform.
Svetlin
08-23-2005 11:17 AM
here is another approach
DATA itab1 TYPE STANDARD TABLE OF mara .
DATA itab2 TYPE STANDARD TABLE OF makt .
DATA: mara_wa LIKE LINE OF itab1 ,
makt_wa LIKE LINE OF itab2 .
DATA ln TYPE i.
SELECT * UP TO 10 ROWS FROM mara INTO TABLE itab1.
PERFORM display TABLES itab1 USING mara_wa .
SELECT * UP TO 10 ROWS FROM makt INTO TABLE itab2.
PERFORM display TABLES itab2 USING makt_wa .
*&---------------------------------------------------------------------*
*& Form display
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_ITAB1 text
* -->P_MARA_WA text
*----------------------------------------------------------------------*
FORM display TABLES p_itab1
USING p_mara_wa.
LOOP AT p_itab1 INTO p_mara_wa .
ENDLOOP .
ENDFORM. " display
Regards
Raja
Message was edited by: Durairaj Athavan Raja
08-23-2005 11:26 AM
Hi,
The problem is solved.Thanks for all the replies.
Christian,
I faced assign type conflict in the code you posted.
If I use USING, I am getting a error in forms stating that 'Non-Standard tables cannot be used in Function module.It can only be used as Exporting or Importing parameters'.
Actually in my requirement, I am passing the itab to a FM tables parameter.
Thanks anyway for your time.
08-23-2005 11:40 AM
Since I typed it directly into this editor - there is no chance of a syntax check.
From what I can see - <l_field> should be type any as well.
Also...
If you use USING you have to change the perform statement as well
PERFORM DISPLAY USING table.
The type conflict can occur if you pass the header line instead of the body. In this case use the brackets as indicated by someone else in a previous posting.
The error message could have the same reason or it could be a unicode error I am not aware of. In this case change the type definition from
FORM display using itab type ANY table
to
FORM display using itab type STANDARD table
If you pass a table without a header line to a FM - make sure to use the brackets.
call function....
TABLES
itab = itab[].
Christian
08-23-2005 10:21 AM
I have accomplished the same using function module. For one of my function module I have not defined the assosiated type and in the program I have assigned this into another internal table which is defined in the TOP include of the function module.
08-23-2005 10:26 AM
Hi Jayanthi,
Try this
PERFORM DISPLAY TABLES ITAB1.
PERFORM DISPLAY TABLES ITAB2.
.
.
.
.
PERFORM DISPLAY TABLES ITAB1 STRUCTURE STRU1.
PERFORM DISPLAY TABLES ITAB2 STRUCTURE STRU2.
You can specify the structure dynamically using the keyword STRUCTURE.
Thanks & Regards,
Kathirvel
08-23-2005 11:44 AM
hi jayanthi.
u analyse this following program , hope u will got solution for ur problem.
DATA: itab TYPE STANDARD TABLE OF spfli,
wa LIKE LINE OF itab.
DATA: line(72) TYPE c,
list LIKE TABLE OF line(72).
START-OF-SELECTION.
line = 'AIRPTO CITYFROM CITYTO COUNTRYFR'.
line = ' AIRPTO '.
APPEND line TO list.
SELECT DISTINCT (list)
INTO CORRESPONDING FIELDS OF TABLE itab
FROM spfli.
IF sy-subrc EQ 0.
LOOP AT itab INTO wa.
WRITE: / wa-cityfrom, wa-cityto , wa-countryfr.
WRITE 😕 wa-airpto.
ENDLOOP.
ENDIF.