5
Thursday, March 15, 2012 We use method CL_WD_RUNTIME_SERVICES=>ATTACH_FILE_TO_RESPONSE to download file from Web Dynpro Application. Example to achieve the functionality Create Web Dynpro Component and Save it a local object. When we specify Window name and View name when we create web dynpro component, View is embedded in Window. Go to Component Controller Context tab->Create node EMP_DET with cardinality 0..n Method tab->Create GET_DATA method to prepare data for EMP_DET node. Follow by Email Followers Join this site with Google Friend Connect Members (50) More » Already a member? Sign in Popular Posts Email address... Find us on Facebook An SAP Consultant 1,267 people like An SAP Consultant. Facebook social plugin Like ABAP ALV Report example with steps 1 Execute ABAP Report using SUBMIT statement 2 Web Dynpro ABAP ALV ON_CLICK e 3 ABAP Sending email with pdf attachm 4 ABAP Step by step tutorial on Smart F Template Node 5 ABAP Dynamic WHERE clause 6 ABAP Download report output as PD 7 SAP ABAP CL_ABAP_CHAR_UTILIT class usage 8 ABAP ALV Demo programs 9 Web dynpro abap Error / Success mes sample program 10 Web Dynpro ABAP Download file An SAP Consultant HOME ABAP ALV SMART FORMS ADOBE FORMS HR ABAP WORKFLOW WEB DYNPRO ABAP HCM

An SAP Consultant_ Web Dynpro ABAP - Download File

Embed Size (px)

DESCRIPTION

sap

Citation preview

  • 08/06/2015 AnSAPConsultant:WebDynproABAPDownloadfile

    http://www.ansapconsultant.com/2012/03/webdynproabapdownloadfile.html 1/5

    Thursday, March 15, 2012

    We use method CL_WD_RUNTIME_SERVICES=>ATTACH_FILE_TO_RESPONSE to download file from Web Dynpro

    Application.

    Example to achieve the functionality

    Create Web Dynpro Component and Save it a local object.

    When we specify Window name and View name when we create web dynpro component, View is embedded in

    Window.

    Go to Component Controller

    Context tab->Create node EMP_DET with cardinality 0..n

    Method tab->Create GET_DATA method to prepare data for EMP_DET node.

    Follow by Email

    Followers

    JointhissitewithGoogleFriendConnect

    Members(50) More

    Alreadyamember?Signin

    Popular Posts

    Emailaddress...

    FindusonFacebook

    AnSAPConsultant

    1,267peoplelikeAnSAPConsultant.

    Facebooksocialplugin

    Like

    ABAPALVReportexamplewithsteps1

    ExecuteABAPReportusingSUBMITstatement

    2

    WebDynproABAPALVON_CLICKevent3

    ABAPSendingemailwithpdfattachment4

    ABAPStepbysteptutorialonSmartFormsTemplateNode5

    ABAPDynamicWHEREclause6

    ABAPDownloadreportoutputasPDFfile7

    SAPABAPCL_ABAP_CHAR_UTILITIESclassusage

    8

    ABAPALVDemoprograms9

    WebdynproabapError/Successmessagesampleprogram

    10

    Web Dynpro ABAP Download file

    An SAP Consultant

    HOME ABAP ALV SMART FORMS ADOBE FORMS HR ABAP WORKFLOW WEB DYNPRO ABAP HCM

  • 08/06/2015 AnSAPConsultant:WebDynproABAPDownloadfile

    http://www.ansapconsultant.com/2012/03/webdynproabapdownloadfile.html 2/5

    Code

    METHODget_data.DATAlo_nd_emp_detTYPEREFTOif_wd_context_node.DATAlt_emp_detTYPEwd_this>elements_emp_det.

    *navigatefromtovialeadselectionlo_nd_emp_det=wd_context>get_child_node(name=wd_this>wdctx_emp_det).SELECT*FROMpa0002INTOCORRESPONDINGFIELDSOFTABLElt_emp_detUPTO30ROWS.lo_nd_emp_det>bind_table(new_items=lt_emp_detset_initial_elements=abap_true

    ENDMETHOD.

    Go to view DOWNLOAD_V

    Context tab->Map Component Controller context to View Context.

    Layout tab->Change layout property of ROOTUIELEMENTCONTAINER to MatrixLayout.

    Layout tab->Create Table UI element ->Bind EMP_DET context node to table element->Set Layout data

    property to MatrixHeadData

    Layout tab->Create Button UI element for downloading file-> Create OnAction event DOWNLOAD_DATA for

    the button.

    Websites I follow

    HTML/CSS/Javscript Generator

    Easy CSS3 Generator

    Digital Inspiration

    Shout ME Loud

    Twitter Feed

    Web Dynpro ABAP Book

  • 08/06/2015 AnSAPConsultant:WebDynproABAPDownloadfile

    http://www.ansapconsultant.com/2012/03/webdynproabapdownloadfile.html 3/5

    Code for theONACTIONDOWNLOAD_DATA method.

    Code

    METHODonactiondownload_data.DATAlo_nd_emp_detTYPEREFTOif_wd_context_node.DATA:lt_emp_detTYPEwd_this>elements_emp_det,ls_emp_detTYPEwd_this>element_emp_det.

    DATA:strTYPEstring,xstrTYPExstring.*navigatefromtovialeadselectionlo_nd_emp_det=wd_context>get_child_node(name=wd_this>wdctx_emp_det).lo_nd_emp_det>get_static_attributes_table(IMPORTINGtable=lt_emp_det).

    "Preparedownloadfile.LOOPATlt_emp_detINTOls_emp_det.CONCATENATEstrls_emp_detpernrls_emp_detnachnls_emp_detvornals_emp_detgbdatcl_abap_char_utilities=>newlineINTOstrSEPARATEDBYcl_abap_char_utilities=>horizontal_tab.ENDLOOP.

    CALLFUNCTION'SCMS_STRING_TO_XSTRING'EXPORTINGtext=strIMPORTINGbuffer=xstrEXCEPTIONSfailed=1."AttachfileCALLMETHODcl_wd_runtime_services=>attach_file_to_response

  • 08/06/2015 AnSAPConsultant:WebDynproABAPDownloadfile

    http://www.ansapconsultant.com/2012/03/webdynproabapdownloadfile.html 4/5

    EXPORTINGi_filename='Download.xls'i_content=xstri_mime_type='EXCEL'i_in_new_window=abap_falsei_inplace=abap_false.ENDMETHOD.

    Methods tab->Call GET_DATA method in WDDOINIT method to get EMP_DET node elements to display in

    Table.

    methodWDDOINIT.DATAlo_componentcontrollerTYPEREFTOig_componentcontroller.lo_componentcontroller=wd_this>get_componentcontroller_ctr().

    lo_componentcontroller>get_data().

    endmethod.

    Save and Activate Web Dynpro component.

    Create Web Dynpro Application and Save it as local object.

    Run Web Dynpro Application.

  • 08/06/2015 AnSAPConsultant:WebDynproABAPDownloadfile

    http://www.ansapconsultant.com/2012/03/webdynproabapdownloadfile.html 5/5

    3 comments:

    Enteryourcomment...

    Commentas: GoogleAccount

    Publish Preview

    Your useful comments, suggestions are appreciated.Your comments are moderated.

    Recommend this on Google

    Sukaniya Mishra May 4, 2013 at 6:26 PM

    I am a SAP ABAP/ITS Consultant. I am working for one of the largest MNC in India as a SAP ABAP/ ITS developer from past one year.During this period I have been working on ABAP and Internet Transaction Server(ITS). My major work has been on ITS(Both of myProjects). So I would like to know whether I should continue working on ABAP/ITS or I should pursue a career in SAP WebDynproand later go SAP EP Cretfication. Which would add much better value to my Career? Working on ABAP or a career in SAPWebDynpro? Well got across this online course for SAP as well. http://www.wiziq.com/course/8153-sap-web-dynpro-pro-abap-trainingWonder it works for me.

    Reply

    john son August 5, 2014 at 2:04 PM

    Wonderful blog & good post.Its really helpful for me, awaiting for more new post. Keep Blogging!

    SAP ABAP Training in Chennai

    Reply

    john son August 5, 2014 at 2:05 PM

    Wonderful blog & good post.Its really helpful for me, awaiting for more new post. Keep Blogging!

    SAP ABAP Training in Chennai

    Reply

    An SAP ConsultantContact US

    About US

    Privacy Policy

    Follow US

    Facebook

    Twitter

    Google

    Want to Contribute ?If you are interested in writing about the new stuff

    you learn everyday while working, please write to

    [email protected].

    Click on Contribution for more details.

    2014ansapconsultant.comAllrightsreserved.