CONSTANTS:
  lc_memidcprog           TYPE char11   VALUE 'ZMEMIDCPROG'.
 
*Variables:
DATA:
  lv_cprog                TYPE sy-cprog,
  lv_cprog_imported       TYPE sy-cprog.
 
*Assigning the program name for demo purposes.
lv_cprog = sy-cprog.
 
*Free the memory ID data before usage.
FREE MEMORY ID lc_memidcprog.
 
*Exporting the program name via memory id.
*Please note that 'LV_DUMMY_CPROG' is just
*a dummary field, no need to declare it.
EXPORT lv_dummy_cprog FROM lv_cprog
TO MEMORY ID lc_memidcprog.
 
*For demo purposes, we will import the variable
*in the same program.
IMPORT lv_dummy_cprog TO lv_cprog_imported
FROM MEMORY ID lc_memidcprog.
 
IF sy-subrc EQ 0.
 
* If the import was successful, write the
* importing program name.
  WRITE lv_cprog_imported.
 
* Its good to free the memory ID data
* after usage.
  FREE MEMORY ID lc_memidcprog.
 
ENDIF.

Serkan AKKAVAK
Computer Engineer
serkurumsal@yandex.com