You are on page 1of 2

8/25/2015

ABAPMEMORYANDSAPMEMORYContributorCornerSCNWiki

GettingStarted Newsletters

Welcome,Guest

Login

Register

Store

SearchtheCommunity

Products

Services&Support

AboutSCN

Downloads

Industries

Training&Education

Partnership

DeveloperCenter

LinesofBusiness

UniversityAlliances

Events&Webinars

Innovation

Weareimproving!Duetofurtherrefinements,ouroriginalplanneddatesfornonewcontentofSeptember4ththroughSeptember7thhavebeenmoved.
TheSCNwikiwillnotbeavailablefornewcontentsubmissionstartingSeptember4th6PMCETuntilSeptember76PMCET.PleaseplanyourSCNwikitasksaccordingly.

ContributorCorner / ContributorCorner

ABAPMEMORYANDSAPMEMORY
AddedbyRSampathKumar,lasteditedbyRSampathKumaronSep03,2014
ABAPMEMORYItusesexportandimportparameterswhenanactiveinternalsession
callsanotherinternalsessionwithinasinglemainsession.
SAPMEMORYItusessetandgetparameterstopassthedatafromonemainsessiontoanothermainsession.

SAPmemoryisamemoryareatowhichallmainsessionswithinaSAPguihaveaccess.YoucanuseSAPmemoryeithertopassdatafromoneprogramtoanotherwithinasession,ortopassdatafrom
onesessiontoanother.ApplicationprogramsthatuseSAPmemorymustdosousingSPA/GPAparameters(alsoknownasSET/GETparameters).Theseparameterscanbeseteitherforaparticular
userorforaparticularprogramusingtheSETPARAMETERstatement.OtherABAPprogramscanthenretrievethesetparametersusingtheGETPARAMETERstatement.Themostfrequentuseof
SPA/GPAparametersistofillinputfieldsonscreens
ABAPmemoryisamemoryareathatallABAPprogramswithinthesameinternalsessioncanaccessusingtheEXPORTandIMPORTstatements.Datawithinthisarearemainsintactduringawhole
sequenceofprogramcalls.Topassdata
toaprogramwhichyouarecalling,thedataneedstobeplacedinABAPmemorybeforethecallismade.Theinternalsessionofthecalledprogramthenreplacesthatofthecallingprogram.Theprogram
calledcanthenreadfromtheABAPmemory.Ifcontrolisthenreturnedtotheprogramwhichmadetheinitialcall,thesameprocessoperatesinreverse.
Externalsession:whenuserlogsontoR/3system,thesystemCreatesanewterminalsessioncalledexternalsession.E.g.SystemSession.
Internalsession:createdbycallingatransaction(withCALLTRANSACTION),adialogmodule(withCALLDIALOG)orareport(withSUBMITorRETURN).
IngeneraleachusercanopenuptosixR/3windowsinasingleSAPguisession.Eachofthesewindowscorrespondstoasessionontheapplicationserverwithitsownareaofsharedmemory.
Thefirstapplicationprogramthatyoustartinasessionopensaninternalsessionwithinthemainsession.TheinternalsessionhasamemoryareathatcontainstheABAPprogramanditsassociateddata.
Whentheprogramcallsexternalroutines(methods,subroutinesorfunctionmodules)theirmainprogramandworkingdataarealsoloadedintothememoryareaoftheinternalsession.
Onlyoneinternalsessioniseveractive.Iftheactiveapplicationprogramcallsafurtherapplicationprogram,thesystemopensanotherinternalsession.Here,therearetwopossiblecases:Ifthesecond
programdoesnotreturncontroltothecallingprogramwhenithasfinishedrunning,thecalledprogramreplacesthecallingprogramintheinternalsession.Thecontentsofthememoryofthecalling
programaredeleted.Ifthesecondprogramdoesreturncontroltothecallingprogramwhenithasfinishedrunning,thesessionofthecalledprogramisnotdeleted.Instead,itbecomesinactive,andits
memorycontentsareplacedonastack.

ThememoryareaofeachsessioncontainsanareacalledABAPmemory.ABAPmemoryisavailabletoallinternalsessions.ABAPprogramscanusetheEXPORTandIMPORTstatementstoaccessit.
Datawithinthisarearemainsintactduringawholesequenceofprogramcalls.Topassdatatoaprogramwhichyouarecalling,thedataneedstobeplacedinABAPmemorybeforethecallismade.The
internalsessionofthecalledprogramthenreplacesthatofthecallingprogram.TheprogramcalledcanthenreadfromtheABAPmemory.Ifcontrolisthenreturnedtotheprogramwhichmadetheinitial
call,thesameprocessoperatesinreverse.

AllABAPprogramscanalsoaccesstheSAPmemory.ThisisamemoryareatowhichallsessionswithinaSAPguihaveaccess.YoucanuseSAPmemoryeithertopassdatafromoneprogramtoanother
withinasession,ortopassdatafromonesessiontoanother.ApplicationprogramsthatuseSAPmemorymustdosousingSPA/GPAparameters(alsoknownasSET/GETparameters).These
parametersareoftenusedtopreassignvaluestoinputfields.Youcansetthemindividuallyforusers,orgloballyaccordingtotheflowofanapplicationprogram.SAPmemoryistheonlyconnection
betweenthedifferentsessionswithinaSAPgui.

******************ABAPMEMORYwithexportandimportparameters****************
REPORTYSP_0136.

data:name1(10)typecvalue'aaaaaaaaaa'.exportname1tomemoryid'MEM1'.SUBMITYSP_0137ANDRETURN.WRITE'SSSSSSSS'.
********************************************************
REPORTYSP_0137.
DATA:NAME2(10)TYPEC.IMPORTNAME1TONAME2FROMMEMORYID'MEM1'.WRITENAME2.

***********ABAPMEMORYwithexportandimportparameters****************
REPORTZPGM1.
data:text1typechar20value'exportandimport'.
exporttext1
text2from'exandim'tomemoryid'MEM'.
SUBMITZPGM2ANDRETURN.
REPORTZPGM2.
DATA:T1TYPECHAR20.

http://wiki.scn.sap.com/wiki/display/Community/ABAP+MEMORY+AND+SAP+MEMORY

1/2

8/25/2015

ABAPMEMORYANDSAPMEMORYContributorCornerSCNWiki

DATA:T2TYPECHAR20.
IMPORTTEXT1TOT1FROMMEMORYID'MEM'.
IMPORTTEXT2TOT2FROMMEMORYID'MEM'.
WRITE:/T1.
WRITE:/T2.
****************************OUTPUT**************
exportandimport
exandim

************ABAPMEMORYwithexportandimportparameters**************
data:t1typechar15value'exandim'.
exportt1tomemoryid'mem'.
t1='xxxxxxxxxx'.
write:/sysubrc,t1.
importt1frommemoryid'mem'."orfreememory.
write:/sysubrc,t1.
t1='xxxxxxxxxx'.
freememoryid'mem'.
importt1frommemoryid'mem'.
write:/sysubrc,t1.
*************outputofprogram****************
0xxxxxxxxxx
0exandim
4xxxxxxxxxx
***************ABAPMEMORYwithexportandimportparameters****************
data:text(10)value'0123456789',
iden(3)value'xyz'.
exporttexttomemoryididen.
text='xxxxxxxxxx'.
importtextfrommemoryididen.
write:/sysubrc,text.
freememory."freememoryididen.
text='xxxxxxxxxx'.
importtextfrommemoryididen.
write:/sysubrc,text.
******************SAPMEMORYwithsetandgetparameters*******************
REPORTYSP_0138.
DATATEXT1(30)TYPECVALUE'SETANDGETPARAMETER'.
SETPARAMETERID'MEM'FIELDTEXT1.
WRITE:'SETPARAMETER'.
*************************************************
REPORTYSP_0139.
DATATEXT2(30)TYPEC.
GETPARAMETERID'MEM'FIELDTEXT2.
WRITE:/TEXT2.
WRITE:'GETPARAMETER'.

Nolabels
ContactUs
Privacy

SAPHelpPortal
TermsofUse

LegalDisclosure

Copyright

http://wiki.scn.sap.com/wiki/display/Community/ABAP+MEMORY+AND+SAP+MEMORY

FollowSCN

2/2

You might also like