Home > ABAP > Load global data in other programs

Load global data in other programs

January 26th, 2010 Leave a comment Go to comments

SAP provides a set of enhancement technologies for custom enhancement. It works well in most situations, but in some case we cannot get the runtime data directly in the program as they are not transferred to the exit or BADI as parameter. In the meantime the database commit is not executed, so we cannot get these data from database.

To solve above problem, we can use key word ASSIGN to load global data into current program which used in other programs.

Syntax

ASSIGN mem_area TO <fs> casting_spec range_spec.

This statement assigns the memory area specified using mem_area to the field symbol <fs>. You can assign a data object or a memory area calculated from the address of a data object. After the assignment, the field symbol refers to the assigned memory area and can be used in operand positions. When used in a statement, it behaves like a dereferenced data reference, meaning that the statement works with the content of the memory area.

The label in mem_area can also have the form (PROG)DOBJ for internal use only, where PROG is the name of an ABAP program and DOBJ is the name of a global data object of this program. If the program PROG is loaded during execution of the statement ASSIGN in the same internal session as the current program, the data object (PROG)DOBJ is searched for in this program, and the field symbol points to this data object after the object has been successfully assigned.

Find Global Data

In general, there are two ways to find global data you want. The first and straight-forward method is read the source code and finds possible data. It will cost abundant time and you must familiar with the program you search.

Another method is to use SAP new debugger. In the new debugger, there is tool called Loaded Programs (Global Data). We can use this tool to view all the loaded programs and global data. If you find the desired data, you can use above statement to load it into current program.

Example

Below code snip shows how to load the global data into the program.

DATA: lv_stru     TYPE char40.
FIELD-SYMBOLS:  TYPE qmnum.
lv_stru = '(SAPLIQS1)IQMNUM’.
 
ASSIGN (lv_stru) TO .
IF sy-subrc = 0.
  MOVE  TO ls_iqmnum.
  ls_iqmnum-n_qmnum = ls_notif_no-qmnum.
  MOVE ls_iqmnum TO .
ENDIF.
  1. No comments yet.
  1. No trackbacks yet.