‎2008 Feb 18 6:00 AM
Hi Friends,
Plz go through my qestion clearly!!!!!!!!!!
You can use SAP memory either to pass data from one program to another within a session,
or to pass data from one session to another. Can any one give example programs for SAP Memory for both scenarios.
1) Pass data from one program to another within a session.
2) Pass data from one session to another.
Note :Please provide example program.
your answer can be given points.
Advance Thanks,
Chandra.
‎2008 Feb 18 6:06 AM
Hi,
in a zprogram write de foll code.
data var type char10.
move 'I luv SDN' to var.
set parameter id 'ZTEST' field var.execute it....open another session....in another zprogram write de foll code.
data var type char10.
get parameter id 'ZTEST' field var.
write var.execute it ull understand.....
donot logoff....bcoz SAP memory gets initialized once u logoff....
Cheers,
jose.
‎2008 Feb 18 6:06 AM
Hi
Check out this program:
&----
*& Report ZSAP_MEMORY *
*& *
&----
*& *
*& *
&----
REPORT zsap_memory NO STANDARD PAGE HEADING
LINE-SIZE 110.
Including the top include.
INCLUDE zsap_memory_top.
************************************************************************
**************002 Declaration of select options and radio buttons*****
************************************************************************
*****************SELECT OPTIONS***************************************
SELECTION-SCREEN BEGIN OF BLOCK blk_selection WITH FRAME.
SELECT-OPTIONS s_purord FOR zekko_68416-ebeln NO-EXTENSION.
" Purchase order
PARAMETERS p_comcd TYPE zekko_68416-bukrs OBLIGATORY.
" Company code
SELECT-OPTIONS s_vendor FOR zekko_68416-lifnr NO INTERVALS.
" Vendor
SELECT-OPTIONS s_date FOR zekko_68416-bedat NO-EXTENSION.
" Purchase order Date
SELECTION-SCREEN END OF BLOCK blk_selection.
********************RADIO BUTTONS*************************************
SELECTION-SCREEN BEGIN OF BLOCK blk_radio WITH FRAME.
PARAMETERS r_clsrep RADIOBUTTON GROUP grp1 DEFAULT 'X'. " classical
PARAMETERS r_alvrep RADIOBUTTON GROUP grp1. " ALV
SELECTION-SCREEN END OF BLOCK blk_radio.
************************************************************************
************end002 Declaration of select options and radio buttons *****
************************************************************************
************************************************************************
***********START OF SELECTION*****************************************
************************************************************************
START-OF-SELECTION.
Calling sub_fetch sub-routine to execute select query
PERFORM sub_fetch .
IF r_clsrep = 'X'.
Calling get_classical sub-routine to display classical report
PERFORM sub_class .
ELSE.
Calling get_avl sub-routine to display alv report
PERFORM sub_alv.
ENDIF.
To Call second screen of the transaction by clicking on any report
line
AT LINE-SELECTION.
Returns the value val_parameter for the particular cursor field
GET CURSOR FIELD g_cursorfield VALUE g_value.
MOVE g_value TO g_value1.
CONDENSE g_value1.
Sets the parameter id.
SET PARAMETER ID 'BES' FIELD g_value1.
CALL TRANSACTION 'ZPUR_06_DISPLAY' AND SKIP FIRST SCREEN .
END-OF-SELECTION.
************************************************************************
****************END OF SELECTION**************************************
************************************************************************
********************TOP OF PAGE************************************
TOP-OF-PAGE.
To display details at the top of every page
WRITE: /3 text-001,sy-uname, 80 text-002,sy-pagno.
WRITE: /3 text-003,sy-cprog, 80 text-004,sy-datlo.
********************END OF PAGE*************************************
END-OF-PAGE.
To display details at the end of every page.
WRITE 😕 text-005.
************************************************************************
****************END OF PROGRAM**************************************
************************************************************************
&----
*& Form sub_class
&----
This subroutine is used to dispaly the data in form of classical
report.
----
FORM sub_class.
*Displaying classical report.
WRITE : /40 'CLASSICAL REPORT'.
WRITE : /(95) sy-uline.
FORMAT COLOR COL_NEGATIVE ON.
Displaying headings.
WRITE : / sy-vline,
5 'PURCHASE ORDER',
23 sy-vline,
25 'LINE ITEM',
37 sy-vline,
39 'MATERIAL',
47 sy-vline,
54 'QUANTITY',
66 sy-vline,
69 'ITEM VALUE',
81 sy-vline,
83 'CURRENCY',
95 sy-vline.
WRITE : /(95) sy-uline.
FORMAT COLOR OFF.
IF sy-subrc = 0.
Sorting the table on Purchase order and currency fields
SORT tbl_matdesc BY g_po g_currency .
check for change in currency
LOOP AT tbl_matdesc.
l_index = sy-tabix + 1.
READ TABLE tbl_matdesc INTO gs_matdesc INDEX l_index.
compare the currencies in tbl_matdesc and gs_matdesc.
IF ( tbl_matdesc-g_currency NE gs_matdesc-g_currency ) OR
( tbl_matdesc-g_po NE gs_matdesc-g_po ).
i_count = i_count + tbl_matdesc-g_item_val.
f_flag2 = 1.
f_flag4 = 1.
c_curr = tbl_matdesc-g_currency.
ELSE.
i_count = i_count + tbl_matdesc-g_item_val.
f_flag3 = '1'.
f_flag4 = 0.
c_curr = tbl_matdesc-g_currency.
ENDIF.
To display alternate colors
FORMAT COLOR COL_HEADING ON.
f_flag1 = f_flag1 MOD 2.
IF ( f_flag1 EQ 0 ).
FORMAT INTENSIFIED ON.
ELSE.
FORMAT INTENSIFIED OFF.
ENDIF.
Displaying the fetched records
WRITE: /(95) sy-uline.
WRITE 😕 sy-vline,
5 tbl_matdesc-g_po,
23 sy-vline,
25 tbl_matdesc-g_item_no,
37 sy-vline,
39 tbl_matdesc-g_material,
47 sy-vline,
49 tbl_matdesc-g_quantity,
66 sy-vline,
69 tbl_matdesc-g_item_val,
81 sy-vline,
83 tbl_matdesc-g_currency,
95 sy-vline.
WRITE : /(95) sy-uline.
f_flag1 = f_flag1 + 1.
To catch the value of purchase order number to be transfred to
transaction screen.
HIDE tbl_matdesc-g_po.
To calculate the sum of Item Value field for every currency type
To print the value of sum of item value.
IF f_flag2 = 1.
IF NOT i_count IS INITIAL.
WRITE sy-uline(82).
FORMAT COLOR COL_POSITIVE ON.
WRITE : / sy-vline,
40 'Total Item Price : ',
57 i_count ,
74 c_curr ,
82 sy-vline.
WRITE / sy-uline(82).
FORMAT COLOR OFF.
CLEAR gs_matdesc.
IF f_flag4 NE 0.
CLEAR i_count.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
IF f_flag3 EQ '1' .
WRITE / sy-uline(82).
FORMAT COLOR COL_POSITIVE ON.
WRITE : / sy-vline,
40 text-007,
57 i_count ,
74 c_curr ,
82 sy-vline.
FORMAT COLOR OFF.
f_flag3 = '0'.
CLEAR gs_matdesc.
ENDIF.
to display a horizontal line
WRITE / sy-uline(82).
ELSE.
WRITE : / text-006.
ENDIF.
ENDFORM. "sub_class
&----
*& Form sub_fetch
&----
This subroutine fetches the data from the database tables and
passes it to internal table tbl_matdesc where the search *
criteria is the given by the user *
----
----
FORM sub_fetch .
SELECT k~ebeln " Purchasing Document Number
bukrs " Company code
lifnr " Vendor
bedat " Purchase Order Date
ebelp " Item Number of Purchasing Document
matnr " Material Number
ktmng " Target quantity
iprice " Item Price
k~waers " Currency
INTO TABLE tbl_matdesc
FROM zekko_68416 AS p
INNER JOIN zekpo_68416 AS k
ON pebeln = kebeln
WHERE bukrs EQ p_comcd AND
p~ebeln IN s_purord AND
lifnr IN s_vendor AND
bedat IN s_date.
ENDFORM. " sub_fetch
&----
*& Form sub_alv
&----
This subroutine is used to display the reprot using ALV Grid *
display.
----
----
FORM sub_alv .
Refeshing catalog of old values
REFRESH : tbl_catalog.
Assigning sort fields to sort table.
wa_sort-fieldname = 'G_CURRENCY'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO tbl_sort.
wa_sort-fieldname = 'G_PO'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO tbl_sort.
doing the sum.
wa_catalog-fieldname = 'G_ITEM_VAL'.
wa_catalog-do_sum = 'X'.
APPEND wa_catalog TO tbl_catalog.
Calling function to Create field catalog from dictionary structure
or internal table
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = 'ZGRP06R_REPORT' " Program
i_internal_tabname = 'TBL_MATDESC' " Internal Table
i_inclname = 'ZGRP06R_REPORT_TOP'
CHANGING
ct_fieldcat = tbl_catalog
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.
Calling function to get Output of a simple list (single-line)
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = tbl_catalog
it_sort = tbl_sort
TABLES
t_outtab = tbl_matdesc " Internal Table
EXCEPTIONS
program_error = 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.
ENDFORM. " sub_alv
Reward points if found useful.
Thanks
Vasudha