Posted: Sun Nov 25, 2007 11:07 pm Post subject: Using a program variable without passing it in parameters
Using a variable from a calling program without passing it in parameters.
Did you ever try to use a variable from another program without passing this variable as a parameter. This is very useful when you CANNOT add the field as a standard parameter. For example, when you want to use a variable in a BADI which is not already passed as a parameter. Another good example is when you create a correction in a function and you want to keep the installation of the OSS note automatic (if you add parameters in a note, the user will have to install the note manually).
Here is a short example on how to do this :
Code:
REPORT zdany_test_var_from_fm.
TABLES: spfli.
DATA dbcnt TYPE sy-dbcnt.
DATA: itab TYPE spfli_tab.
SELECT * FROM spfli INTO TABLE itab UP TO 2 ROWS.
dbcnt = sy-dbcnt.
CALL FUNCTION 'ZFUNCTION'.
FUNCTION zfunction.
* We want to use the DBCNT from the program ZDANY_TEST_VAR_FROM_FM
DATA: field(50).
FIELD-SYMBOLS: <dbcnt>.
field = '(ZDANY_TEST_VAR_FROM_FM)dbcnt'.
ASSIGN (field) TO <dbcnt>.
WRITE <dbcnt>.
* We want to use the internal table from the program ZDANY_TEST_VAR_FROM_FM
DATA: itab TYPE spfli.
FIELD-SYMBOLS: <itab> TYPE spfli_tab.
field = '(ZDANY_TEST_VAR_FROM_FM)ITAB[]'.
ASSIGN (field) TO <itab>.
LOOP AT <itab> INTO itab.
WRITE: / itab-carrid, itab-connid.
ENDLOOP.
ENDFUNCTION.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.