Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 3575

How to generate generic internal table output in a FM using Field Symbols

$
0
0

Hello all

 

I will try to explain my requirement here.

 

I want to create a (RFC) function module which accepts a couple of input parameters and update an internal table which can be called by another FM.

 

Here is my FM (changed something for privacy purpose):

FUNCTION ZFM_TEST.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(PARAMETER1) TYPE  SOMETHING "changed for the SCN discussion
*"     REFERENCE(PARAMETER2) TYPE  SOMETHING
*"  TABLES
*"      IT_OUTTAB
*"----------------------------------------------------------------------   DATA: TAB_NAME TYPE STRING.   DATA: R_TABLE TYPE REF TO DATA.   FIELD-SYMBOLS: <TAB> TYPE STANDARD TABLE.   FIELD-SYMBOLS:  <WA_TAB> TYPE DATA.
" some code to know the table name based on import parameters   CREATE DATA R_TABLE TYPE TABLE OF (TAB_NAME).   ASSIGN R_TABLE->* TO <TAB>.   CREATE DATA R_TABLE LIKE LINE OF <TAB>.   ASSIGN R_TABLE->* TO <WA_TAB>.   SELECT * FROM (TAB_NAME) INTO TABLE <TAB>.   IT_OUTTAB = <TAB>.
ENDFUNCTION.

My code successfully populates <TAB>. I need to update the records in that <TAB> in the IT_OUTTAB. The code fails at line IT_OUTTAB=<TAB>. I have also tried GET REFERENCE statement but that fails too.

 

I have searched a lot of field symbols and internal table and dynamic internal table but nothing is providing me the desired result.

 

My requirement is that whatever fields and records are there in <TAB>, the same thing gets replicated in IT_OUTTAB. When I call this FM and pass parameters, I should be able to get IT_OUTTAB filled for subsequent processing.

 

My apologies if I could not search correctly. ABAP is not my core skill. Some links that I tried:

**************** - Dynamic Internal Table

Google

Google

Google

 

Hope the requirement is clear.


Viewing all articles
Browse latest Browse all 3575

Trending Articles