‎2005 Dec 16 8:49 AM
hi all ,
I have two function Module with different structute with the same Table name parameter
Like in FM1 :
Tables : I_Tab Like Structure1
And Second FM2 Program2 :
Tables : I_Tab Like Structure2
And this two FM will call my Function module which i need to built with the same processing for both.
So, Can i create a dynamic structure based on the caller FM.
That is if FM1 Calls then I create I_Tab with Stru1
and if FM2 Calls then I create I_Tab with Stru2
Hope i m clear to present my problem
Praff
‎2005 Dec 16 9:05 AM
Hi
You can try to use this solution:
DATA: GT_FIELDCAT TYPE LVC_T_FCAT.
DATA: MY_TABLE TYPE REF TO DATA,
MY_WORKAREA TYPE REF TO DATA.
FIELD-SYMBOLS: <TABLE> TYPE TABLE,
<WA> TYPE ANY.
DATA: STRACTURE_NAME LIKE DD02L-TABNAME.
Create internal table
IF FM = FM1
STRACTURE_NAME = .....
ELSE.
STRACTURE_NAME = .....
ENDIF.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = STRUCTURE_NAME
I_CLIENT_NEVER_DISPLAY = 'X'
I_BYPASSING_BUFFER =
CHANGING
CT_FIELDCAT = GT_FIELDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
I_STYLE_TABLE =
IT_FIELDCATALOG = GT_FIELDCAT
IMPORTING
EP_TABLE = MY_TABLE
E_STYLE_FNAME =
EXCEPTIONS
GENERATE_SUBPOOL_DIR_FULL = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ASSIGN MY_TABLE->* TO <TABLE>.
Create work area
CREATE DATA MY_WORKAREA LIKE LINE OF <TABLE>.
ASSIGN MY_WORKAREA->* TO <WA>.
or this:
DATA: ITAB1 LIKE STANDARD TABLE OF <STRUCTURE1>,
ITAB2 LIKE STANDARD TABLE OF <STRUCTURE2>.
FIELD-SYMBOLS: <TABLE> TYPE TABLE.
IF FM = FM1
ASSIGN ITAB1 TO <TABLE>.
ELSE.
ASSIGN ITAB2 TO <TABLE>.
ENDIF.
Max
Message was edited by: max bianchi
Message was edited by: max bianchi
‎2005 Dec 16 9:25 AM
hi thanks
But caller function module is passing the values to my function module .
so how to do that >
that is how to use that data from caller fm
Praff
‎2005 Dec 16 10:14 AM
Hi
Your fm should have a parameter table without reference, so it'll have the structure of the table transfered from caller.
Can you give me your code where you manage this calling?
Max
‎2005 Dec 16 11:41 AM
‎2009 Jan 06 2:16 AM