0% found this document useful (0 votes)
152 views5 pages

Abap Trapdoors - Call Transformation Id (Ontwork) - Sap Blogs

Abap Trapdoors_ Call Transformation Id(Ontwork) _ Sap Blogs

Uploaded by

Srikanth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
152 views5 pages

Abap Trapdoors - Call Transformation Id (Ontwork) - Sap Blogs

Abap Trapdoors_ Call Transformation Id(Ontwork) _ Sap Blogs

Uploaded by

Srikanth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

201766 ABAPTrapdoors:CALLTRANSFORMATIONid(ontwork)|SAPBlogs

Products
Products Industries
Industries Support
Support Training
Training Community
Community Developer
Developer Partner
Partner

About
About


Home / Community / Blogs + Actions

ABAPTrapdoors:CALLTRANSFORMATION
id(ontwork)
June5,2015 | 332Views |
VolkerWegert
morebythisauthor

ABAPDevelopment

abap | abapobjects | abapoo | transformation

share
1 share
0 tweet share
0

Follow

https://blogs.sap.com/2015/06/05/abaptrapdoors/ 1/5
201766 ABAPTrapdoors:CALLTRANSFORMATIONid(ontwork)|SAPBlogs

WelcometoanotherABAPTrapdoorsarticlethefirstonepostedusing
mynewSCNuser.Ifyouareinterstedintheolderarticles,youcanfind
alinklistatthebottomofthispost.

IvebeenusingasXMLforsomeyearsnowasaconvenientwayto
serializeanddeserializearbitraryABAPdatastructures.Sometimeago,
IlearnedaboutIF_SERIALIZABLE_OBJECTanditsusetoincludeclass
instances(akaobjects)inanasXMLrepresentationaswell.Afewdays
ago,Idecidedtousethistechniqueinacurrentdevelopmentproject.At
thesametime,IwastryingtouseCL_DEMO_OUTPUT_STREAMinsteadof
classiclistsassuggestedbytheonlinedocumentation,andsinceIwas
supposedlyfamiliarwiththebasicsofusingtransformations,Ifocused
ratherontheusageofthisnewoutputtechnology.Ihackedtogethera
smalldemoprogrammlikethisone:

REPORTz_test_serialize.
CLASSlcl_serializable_thingyDEFINITIONCREATEPUBLIC.
PUBLICSECTION.
INTERFACESif_serializable_object.
METHODSconstructor
IMPORTING
i_fooTYPEstring.
METHODSget_foo
RETURNING
VALUE(r_foo)TYPEstring.
PRIVATESECTION.
DATAg_fooTYPEstring.
ENDCLASS.
CLASSlcl_serializable_thingyIMPLEMENTATION.
METHODconstructor.
g_foo=i_foo.
ENDMETHOD.
METHODget_foo.
r_foo=g_foo.
ENDMETHOD.
ENDCLASS.
CLASSlcl_mainDEFINITIONCREATEPRIVATE.
PUBLICSECTION.
CLASSMETHODSrun.
ENDCLASS.
CLASSlcl_mainIMPLEMENTATION.
METHODrun.
DATA:lr_streamTYPEREFTOcl_demo_output_stream,
l_foo_inTYPEstring,
lr_first_thingyTYPEREFTOlcl_serializable_thingy,
l_xml_dataTYPEstring,
lr_second_thingyTYPEREFTOlcl_serializable_thingy,
l_foo_outTYPEstring.
lr_stream=cl_demo_output_stream=>open().
SETHANDLERcl_demo_output_html=>handle_outputFORlr_stream.
https://blogs.sap.com/2015/06/05/abaptrapdoors/ 2/5
201766 ABAPTrapdoors:CALLTRANSFORMATIONid(ontwork)|SAPBlogs

lr_stream>write_text(iv_text='XMLSerializationofABAPObjectsInstances'
iv_format=if_demo_output_formats=>heading
iv_level=1).
l_foo_in=|Hello,thisisFooBarcallingfrom{sysysid}client{symandt}.|.
lr_stream>write_data(iv_name='InputData'
ia_value=l_foo_in
iv_format=if_demo_output_formats=>nonprop).
CREATEOBJECTlr_first_thingy
EXPORTING
i_foo=l_foo_in.
CALLTRANSFORMATIONid
SOURCEinstance=lr_first_thingy
RESULTxml=l_xml_data.
lr_stream>write_data(iv_name='XMLSerialization'
ia_value=l_xml_data
iv_format=if_demo_output_formats=>nonprop).
CALLTRANSFORMATIONid
SOURCExml=l_xml_data
RESULTinstance=lr_second_thingy.
l_foo_out=lr_second_thingy>get_foo().
lr_stream>write_data(iv_name='OutputData'
ia_value=l_foo_out
iv_format=if_demo_output_formats=>nonprop).
lr_stream>close().
ENDMETHOD.
ENDCLASS.
STARTOFSELECTION.
lcl_main=>run().

Insteadoftheexpectedoutput(sometext,anXMLrepresentationofthe
instanceandthesametextagain),Igotashortdump.Thereference
lr_second_thingywasnotsetafterthesecondtransformationso
thedeserializationmustsomehowbebroken,right?Thedebugger
quicklyrevealedthatthestringvariablethatwassupposedtocontain
theserializedinstancewasemptysoitstheserializationthatmustbe
broken,then,andnotthedeserialization?Well,theybothare,inaway.
Tocutstraighttothepoint,hereisthefaultycode:

CALLTRANSFORMATIONid
SOURCEinstance=lr_first_thingy
RESULTxml=l_xml_data.
lr_stream>write_data(iv_name='XMLSerialization'
ia_value=l_xml_data
iv_format=if_demo_output_formats=>nonprop).
CALLTRANSFORMATIONid
SOURCExml=l_xml_data
RESULTinstance=lr_second_thingy.

https://blogs.sap.com/2015/06/05/abaptrapdoors/ 3/5
201766 ABAPTrapdoors:CALLTRANSFORMATIONid(ontwork)|SAPBlogs

Andhereisthecorrectedversion:

CALLTRANSFORMATIONid
SOURCEinstance=lr_first_thingy
RESULTXMLl_xml_data.
lr_stream>write_data(iv_name='XMLSerialization'
ia_value=l_xml_data
iv_format=if_demo_output_formats=>nonprop).
CALLTRANSFORMATIONid
SOURCEXMLl_xml_data
RESULTinstance=lr_second_thingy.

Yup,thedifferenceisasinglecharacterortwocharactersinthiscase.
Withouttheequalssign,XMListreatedasakeywordtodenotea
variablecontainingtherawXMLdata.Withtheequalssign,something
elsehappensthatIhaveyettofindasensibleandpracticaluseforat
leastwhenusedwiththeidentitytransformation.Youcanspotthisissue
ifyouusetheprettyprintertoconvertthekeywordstouppercaseand
ifyounoticethetinydifferencebetweenxmlandXML.

OlderABAPTrapdoorsarticles

20110307:TheMythoftheInstanceConstructor
20110325:MorphingMethodParameters
20110428:LOOPDizziness
20110629:AmomentaryWEAKness
20111005:TypeLockIn
20111121:DeathBySTRING
20141114:RFConversiononaSTRING

AlertModerator

Bethefirsttoleaveacomment
YoumustbeLoggedontocommentorreplytoapost.

https://blogs.sap.com/2015/06/05/abaptrapdoors/ 4/5
201766 ABAPTrapdoors:CALLTRANSFORMATIONid(ontwork)|SAPBlogs

Share&Follow
Privacy TermsofUse LegalDisclosure Copyright Trademark Sitemap Newsletter

https://blogs.sap.com/2015/06/05/abaptrapdoors/ 5/5

You might also like