Académique Documents
Professionnel Documents
Culture Documents
|SCN
SearchtheCommunity
Products Services&Support AboutSCN Downloads
2
SearchAllofSAP
Activity Communications Actions
Industries Training&Education Partnership DeveloperCenter
craig.cmehil
BSP/HowTo:GeneratePDFOutputfromaBSP.
PostedbyCraigCmehilincraig.cmehilonNov10,200410:58:25PM
Haveyoueverheardthecommentfromsomeone,"BoyIsurewouldliketogetthisreportasaPDFonmycomputerin
ordertosendittoBoboverinaccounting.Hedoesn'thavealoginforthisBSPapplicationandit'dbegreattosend
himthisdata."WellIhaven'teither,OK,notexactlylikeitbutsimiliar.Itleftmewithtwochoices,1,give"Bob"aloginor
2,figureouthowtooutputmyreportasPDF.
BeingafrequentvisitortoSDNIrememberedreadingafewthingsaboutPDFandoutputingsoIbeganmy
searching...
BSPProgramming:HandlingOfNonHTMLDocuments
Generatefile.docor.pdfasfromatext
Wellafterplayingaroundwiththeinformation,andImeanreallygoodinformationgivenintheseposts/weblogsI
realizedthatIstillhadafewquestionsleftunanswered.Namely,"HowdoIgetthedataasOTF?".
ThisleadmetopostanewtopicintheBSPforumcalledPDFoutputandwiththehelpmyfellowSDNersIthinkwe've
comeupwithalltheinfoneededtoenlightenthosestubmlingaroundinthedarklikemyself.
Specialthanksgooutto...
DurairajAthavanRaja
UlliHoffmann
SubramanianVenkateswaran
EddyDeClercq
Sowecamedowntobasically3majorpossibilitiesfordoingthis.
FM:CONVERT_OTF
FM:CONVERT_ABAPSPOOLJOB_2_PDF
ExternalTools
Togetstartedlet'screateourBSPpage.
PageLayout
http://scn.sap.com/people/craig.cmehil/blog/2004/11/10/bsphowtogeneratepdfoutputfromabsp 1/15
29/7/2015 BSP/HowTo:GeneratePDFOutputfromaBSP.|SCN
\<%@pagelanguage="abap"%>\<%@extensionname="htmlb"
prefix="htmlb"%>\<htmlb:contentdesign="design2002">\
<htmlb:page>\<htmlb:formmethod="post"\
encodingType="multipart/formdata">\<htmlb:radioButtonGroup
id="display_type">\<htmlb:radioButtonid="inline"
\text="DisplayInline"/>\
<htmlb:radioButtonid="html"\text=
"DisplayInsideHTMLPage"/>\<htmlb:radioButtonid=
"window"\text="DisplayInNewWindow"
/>\<htmlb:radioButtonid="convert"
\text="ConverttoPDFInsideHTMLPage"
/>\<htmlb:radioButtonid="convertnew"
\text="ConvertSystemTableListtoPDF
InNewWindow"/>\<htmlb:radioButtonid="convertspool"
\text="ConvertSystemTableListtoPDF
InNewWindow(SPOOL)"/>\</htmlb:radioButtonGroup>\
<htmlb:fileUploadid="myUpload"\
onUpload="HandleUpload"\upload_text=
"Display"\size="90"/>\
<hr>\<br>Name=<%=file_name%>\<br>MIMEType=<%=
file_mime_type%>\<br>Length=<%=file_length%>\<%\
IF(display_type='html'ORdisplay_type='convert')AND
display_urlISNOTINITIAL.\%>\<iframesrc="<%=
display_url%>"_mce_src="/<%=display_url%>"width="100%"
height="500px">\</iframe>\<%\ENDIF.\IF(
display_type='window'ORdisplay_type='convertnew')AND
display_urlISNOTINITIAL.\%>\<mce:script
language="Javascript"><!\window.open("<%=
display_url%>").focus();\//></mce:script>\<%\
ENDIF.\%>\</htmlb:form>\</htmlb:page>\
</htmlb:content>\
\
ThisisbasicallythecodefromBrian'sweblogwithacoupleofnewradiooptions.
PageAttributes
style="width:350pxborder:thininsetbackground:lightgreybackgroundcolor:lightgrey">\content\
TYPE\STRING
display_type\TYPE\STRING
display_url\TYPE\STRING
file_content\TYPE\XSTRING
file_length\TYPE\STRING
file_mime_type\TYPE\STRING
file_name\TYPE\STRING
OnInputProcessing
http://scn.sap.com/people/craig.cmehil/blog/2004/11/10/bsphowtogeneratepdfoutputfromabsp 2/15
29/7/2015 BSP/HowTo:GeneratePDFOutputfromaBSP.|SCN
\*eventhandlerforcheckingandprocessinguserinputand\*for
definingnavigation\\DATA:radioButtonGroupTYPEREFTO
CL_HTMLB_RADIOBUTTONGROUP.\DATA:fileUploadTYPEREFTO
CL_HTMLB_FILEUPLOAD.\DATA:cached_responseTYPEREFTO
if_http_response.\DATA:responseTYPEREFTOif_http_response.\
DATA:guidTYPEguid_32.\\fileUpload?=
CL_HTMLB_MANAGER=>GET_DATA(\request=
request\id='myUpload'
\name='fileUpload').\\
file_name=fileUpload>file_name.\file_mime_type=
fileUpload>file_content_type.\file_length=fileUpload
>file_length.\file_content=fileUpload>file_content.\\
radioButtonGroup?=CL_HTMLB_MANAGER=>GET_DATA(
\request=request\
id='display_type'\name=
'radioButtonGroup').\\display_type=radioButtonGroup
>selection.\\IFdisplay_type='inline'ANDXSTRLEN(file_content
)>0.\response=runtime>server>response.\response
>set_data(file_content).\response>set_header_field(name=
if_http_header_fields=>content_type\
value=file_mime_type).\"response>set_header_field(name=
if_http_header_fields=>content_length\
"value=file_length).\response
>delete_header_field(name=if_http_header_fields=>cache_control).
\response>delete_header_field(name=
if_http_header_fields=>expires).\response>delete_header_field(
name=if_http_header_fields=>pragma).\navigation
>response_complete()."signalthatresponseiscomplete\\
RETURN.\ENDIF.\\IF(display_type='html'ORdisplay_type=
'window')ANDXSTRLEN(file_content)>0.\\CREATEOBJECT
cached_responseTYPECL_HTTP_RESPONSEEXPORTINGadd_c_msg=1.\\
cached_response>set_data(file_content).\cached_response
>set_header_field(name=if_http_header_fields=>content_type
\value=file_mime_type).\
cached_response>set_status(code=200reason='OK').\
cached_response>server_cache_expire_rel(expires_rel=180).\\
CALLFUNCTION'GUID_CREATE'\IMPORTING\ev_guid_32=
guid.\CONCATENATEruntime>application_url'/'guidINTO
display_url.\\cl_http_server=>server_cache_upload(url=
display_url\response=
cached_response).\RETURN.\\ENDIF.\
ThattherewillgetallofthenormalstuffworkingthatBriandescribesinhisweblogondealingwithNONHTML
documents.
Nowlet'sgointoeachofthese3possibilitesandseewhichoneworksbestforyou...
FM:CONVERT_OT
Thisseemstobethebestpossiblesolutiontobehonestwithyou,Ilikethisone.NotsurewhybutIdo.Firstthingsfirst
isthatyouhavetocreateaSmartForm(transactionSMARTFORMS)andonceyoucreatetheSmartFormjustinthe
menuclickENVIRONMENTFUNCTIONMODULENAME.YouseeonceyoucreatetheSmartFormandactivateitit
generatesafunctionmodule.
Let'smakeaSmartForm
IstartedbycallingtransactionSMARTFORMS,thereIgavemySmartFormanameandselected"CREATE"
OncecreatedIstartedtoedittheSmartForm,thefirststepwastheFormInterface,Ienteredmytableparametersthere.
http://scn.sap.com/people/craig.cmehil/blog/2004/11/10/bsphowtogeneratepdfoutputfromabsp 3/15
29/7/2015 BSP/HowTo:GeneratePDFOutputfromaBSP.|SCN
ThenIdefinedmyglobalvariablesforthetableandthetablestructure.
ThenontheInitalizationtaboftheGlobalsectionIwasabletoinitializemytable.
ThensimplyclickonyourPageandyoucanthencreateatableelement,whichthenunderthedatatableyoudefine
yourtableLOOP.
ThenfortestpurposesIsimplyaddedonecellofdataandonetextlabeltothecell,thendraggedfrommyfieldlistbox
thenameofonecelltothenewtextbox.
http://scn.sap.com/people/craig.cmehil/blog/2004/11/10/bsphowtogeneratepdfoutputfromabsp 4/15
29/7/2015 BSP/HowTo:GeneratePDFOutputfromaBSP.|SCN
OncethatwasallcompleteIwasableto"activate"theSmartFormandthengetthefunctionmodulenamefromthe
menuoption.
SogotyourSmartForm?OK,thenlet'smodifyourcodetoaddinforthat.GotoyourOnInputProcessingEventHandler
andappendthistothebottomoftheexistingcode.
OnInputProcessing
\IFdisplay_type='convert'ORdisplay_type='convertnew'.\\*
generatedresult:PDFformat\data:l_pdf_xstringtypexstring,
\lt_linestypetableoftline,\
ls_linetypetline,\l_pdf_lentypei.\\
data:output_optionstypessfcompop,\
control_parameterstypessfctrlop,\output_data
typessfcrescl,\devtypetyperspoptype.\\
data:lt_systypetableofzsystems.\\control_parameterslangu
=sylangu.\control_parametersno_dialog='X'.\
control_parametersgetotf='X'.\\select*fromzsystems
intotablelt_sys.\\callfunction'SSF_GET_DEVICE_TYPE'\
EXPORTING\i_language=sylangu\IMPORTING
\e_devtype=devtype\EXCEPTIONS\
no_language=1\language_not_installed=2\
no_devtype_found=3\system_error=4\
others=5.\\*setdevicetypeinoutputoptions
\output_optionstdprinter=devtype.\\callfunction
'/1BCDWB/SF00000001'\EXPORTING\user_settings=
space\control_parameters=control_parameters\
output_options=output_options\IMPORTING\
job_output_info=output_data\TABLES\
zsystems=lt_sys\EXCEPTIONS\
formatting_error=1\internal_error=2\
send_error=3\user_canceled=4\
others=5.\\callfunction'CONVERT_OTF'\
EXPORTING\format='PDF'\IMPORTING
\bin_filesize=l_pdf_len\
bin_file=l_pdf_xstring\TABLES\
OTF=OUTPUT_DATAOTFDATA\
LINES=LT_LINES\EXCEPTIONS\
err_max_linewidth=1\err_format=2\
err_conv_not_possible=3\err_bad_otf=4\
others=5.\\ifsysubrcEQ0.\\CREATE
OBJECTcached_responseTYPECL_HTTP_RESPONSEEXPORTINGadd_c_msg=1.
\\l_pdf_len=xstrlen(l_pdf_xstring).\cached_response
>set_data(data=l_pdf_xstring\length=
l_pdf_len).\\cached_response>set_header_field(name=
if_http_header_fields=>content_type
\value='application/pdf').
\cached_response>set_status(code=200reason='OK').\
cached_response>server_cache_expire_rel(expires_rel=180).\
\CALLFUNCTION'GUID_CREATE'\IMPORTING\
ev_guid_32=guid.\CONCATENATEruntime>application_url'/'
guid'.pdf'INTOdisplay_url.\\
cl_http_server=>server_cache_upload(url=display_url
\response=cached_response
).\\ENDIF.\\RETURN.\\ENDIF.\
AsyoucanseewegiveournowselectedtableofdatatotheSmartFormforprocessingandthentheOTFencoded
resultsfromtheSmartFormtotheCONVERT_OTFFMforprocessing.
Didyoutryit?DidyougetyourPDFfilelikeme?
FM:CONVERT_ABAPSPOOLJOB_2_PDF
Rajaprovidedanicecodesampletoworkwithforthisoption.
http://scn.sap.com/people/craig.cmehil/blog/2004/11/10/bsphowtogeneratepdfoutputfromabsp 5/15
29/7/2015 BSP/HowTo:GeneratePDFOutputfromaBSP.|SCN
\callfunction'GET_PRINT_PARAMETERS'\EXPORTING\
destination=loc_dest\copies=wf_copies\
list_name=wf_listname\list_text=wf_listtext\
immediately=''\release=''\new_list_id
='X'\expiration=wf_days\line_size=200\
line_count=65\layout='X_65_200'\
sap_cover_page='X'\receiver='SAP*'\
department=''\no_dialog='X'\IMPORTING\
out_parameters=wf_params\valid=wf_valid.\\if
wf_valid<>space.\newpageprintonparameterswf_paramsno
dialog.\\*usingthenormalABAPwritestatement\*writethe
contentshere\*(e.gWrite:/'Thisisfortesting'\\newpage
printoff.\endif.\
sysponowillthencontainyourSpoolnumberwhichyoucanthenusewiththefunctionmodule
CONVERT_ABAPSPOOLJOB_2_PDFwiththeSpoolnumberasaparameter.Thiswillreturnatable,PDF
STRUCTURETLINE,whichyoucanthensavewith.pdfextension.AsRajapointedout"Ihaventtriedthismyself
insideaBSPapplication,butifeelthatitshouldwork."
FromalogicpointofviewIwillsaythatsincethenormalABAPwritestatementsdon'tworkdirectlyintheBSPyou
wouldhavetoreallythinkhardtofigureouthowtogetthistowork.Wearenowattemptingtodojustthatandwillpost
backwithanupdatetotheweblogifwefigureitout.
Anotheroptionwouldbeifyouhadthespoolnumberfirst,forexamplefromaselectlistorsomething.Youwouldbeas
dynamicaswiththeSmartFormmethodbutitshouldalsowork,justgottaconvertyourPDFtabletoXSTRING.
\IFdisplay_type='convertspool'.\\DATA:itabTYPETLINE,
\witabTYPETABLEOFTLINE,\outputTYPESTRING,
\outputxTYPEXSTRING.\\callfunction
'CONVERT_ABAPSPOOLJOB_2_PDF'\EXPORTING\
SRC_SPOOLID=9553\NO_DIALOG=
'X'\TABLES\PDF=witab\
EXCEPTIONS\ERR_NO_ABAP_SPOOLJOB=1\
ERR_NO_SPOOLJOB=2\ERR_NO_PERMISSION=3
\ERR_CONV_NOT_POSSIBLE=4\ERR_BAD_DESTDEVICE
=5\USER_CANCELLED=6\
ERR_SPOOLERROR=7\ERR_TEMSEERROR=8
\ERR_BTCJOB_OPEN_FAILED=8\ERR_BTCJOB_SUBMIT_FAILED
=9\ERR_BTCJOB_CLOSE_FAILED=10\
others=11.\\ifsysubrcEQ0.\LOOPAT
witabINTOitab.\CONCATENATE\output\itab
tdline\INTOoutput.\ENDLOOP.\\****Convertthe
CharacterStringtoBinaryString\data:r_stringtypestring.
\data:R_XSTRINGtypexstring.\\callfunction
'SCMS_STRING_TO_XSTRING'\EXPORTING\text=output
\IMPORTING\buffer=outputx.\\CREATEOBJECT
cached_responseTYPECL_HTTP_RESPONSEEXPORTINGadd_c_msg=1.\
\l_pdf_len=xstrlen(outputx).\cached_response
>set_data(data=outputx\length=
l_pdf_len).\\cached_response>set_header_field(name=
if_http_header_fields=>content_type
\value='application/pdf').
\cached_response>set_status(code=200reason='OK').\
cached_response>server_cache_expire_rel(expires_rel=180).\
\CALLFUNCTION'GUID_CREATE'\IMPORTING\
ev_guid_32=guid.\CONCATENATEruntime>application_url'/'
guid'.pdf'INTOdisplay_url.\\
cl_http_server=>server_cache_upload(url=display_url
\response=cached_response
).\\ENDIF.\\RETURN.\\ENDIF.\
Ithinkthatshouldwork,wewillkeepyoupostedonfurtherdevelopmentsusingthismethod.
HereisasolutionfromRaja:SPOOLTOPDF
http://scn.sap.com/people/craig.cmehil/blog/2004/11/10/bsphowtogeneratepdfoutputfromabsp 6/15
29/7/2015 BSP/HowTo:GeneratePDFOutputfromaBSP.|SCN
ExternalTools
Nowtherearelotsofthesetoolsoutthere,EddypointsoutHTMLDOC.Eddygoesontotellusthatallwehavetois
"ThewaytogoistoinstallHTMLDOC,thenmakeanexternalcommand.InyourBSPpage(withextensionpdf,is
neededforMIE)makeyouHTMLandwriteittotempfile.Calltheexternalcommandwiththetempfileasinput.Then
readthepdfandsetitascontentandsetallresponseheadersforpdf.Cleanupthetempfiles.Itworksgoodandfast.
TherearealsoJAVAandActiveXtoolsoutthereaswell.Eachofyouwillhavetodecideyourownstrategyofcourse.
Personallyifthesystemcanalreadydoitthenwhyinstallanothercomponentthatyoumayhavetoworryabout
compatabilityissueswithinthefuture?
Wheredoesallthisleaveus?
Soasyoucanseethereareoftenmanypossiblitiesforproblemsyouencounteranditisjustamatterofdeciding
whichoneworksbestforyou.InthiscasedoesitmakesensetocreateaSmartFormforeachandeveryitemyouwant
toprintout?PerhapsifyouhaveaCorporateIdentitythatyoumustadheretothenthiscouldbethebestway.
The"spool"seemslikeagreatchoicesimplybecauseyoudon'thavecreateaSmartFormfirst.Infactacleverperson
mightjusthaveaABAPreportthatrunsandcreatestheSpooloutputsandthenaBSPwhichletsapersonselectan
existingSpoolandthenretrieveitasPDF.
Externaltoolsarealwaysavailableandtherearelotsofthemoutthere,however,youhavetoaskyourself"Doyou
reallywanttoaddacomponentthatmaynotbecompatibleafterthenextSPorRelease?".Theseareproblemsthat
sometimesariseaswemoveintothefuture,whereas,aninternalsolutionsuchasSmartFormsorABAPSPOOLto
PDFwellthoseIthinkwillbesupportedinthefuture.
PleaseconsiderthisweblogaworkinprogressasIdon'tthinkwe'veheardtheendofoureffortswithABAPSpooland
I'msuretherearequiteafewmorepossiblesolutionsoutthereandIhopeyou'llshareyourswithusaswell!
Whatthefutureholds!!
FromMatthiasZeller,IndeedInteractiveFormsisthe"nextgeneration"formstoolinSAP(andnotonlyforinteractive,
butalsoforprintforms).ItisavailablestartingwithWebAS6.40.SmartFormsandSAPscriptwillbecontinuetobe
availablebutallnewdevelopmentaroundSAPformswillbedoneinthenewInteractiveForms.TheAdobedocument
services(ADS)whicharepartofInteractiveFormscangeneratedifferentoutputincludingPDF,PS,PCLandZPL(for
ZebraLabelprinters).
SowithInteractiveFormsyouwillbeabletogeneratePDFinanSAPsystemnativelybymergingformsdatawitha
formtemplate(soyoudonotneedtocreateOTFanymoreandusetheCONVERT_OTFlibrariestogeneratePDF).
ThiscanbeconfiguredinABAPusingtransactionSFPorwithWebDynproforJavatocreatePDFdocuments
embeddedinaWebUI(andinthefuturealsowithWebDynproforABAP).
ThePDFsgeneratedwithADSareactuallythelatestversionPDF1.6andcanbemadeaccessibletoblindpeoplevia
screenreaders.
Tips:
FromJonathanBourne,JustwantedtomentionthatratherthanhuntingfortheSmartformsfunctionmodulenamethe
followingfunctionmodulecanbeused:
SSF_FUNCTION_MODULE_NAME
ThisFMtakestheSmartformnameandreturnsthefunctionmodulename.Thisisamorerobustsolutionasthe
SmartformmayreceiveadifferentFMnamewhenitistransportedtoothersystems.
3627Views
AverageUserRating
MyRating:
(1rating)
33Comments
SubramanianVenkateswaranNov10,200411:01PM
Wellyoufinallydidit,greatjob,Craig.
WithoutanyhelpofSMARTFORMSfromABAPprogrammingforum(thereyougo!!!).
Thanksamillionfortheweblog,makesitsomucheasier.
Regards,
SubramanianV.
http://scn.sap.com/people/craig.cmehil/blog/2004/11/10/bsphowtogeneratepdfoutputfromabsp 7/15
29/7/2015 BSP/HowTo:GeneratePDFOutputfromaBSP.|SCN
(Thanksforputtingmeinthespotlight:P)
Like(0)
CraigCmehilNov10,200411:07PM(inresponsetoSubramanianVenkateswaran)
YoudeserveasmuchcreditasIdoforthiseffort!
IstruggledforafewhoursontheSmartFormokit'saverybasiconebutitdidthetrickfor
testingpurposes:)
Like(0)
SubramanianVenkateswaranNov14,20049:56PM(inresponsetoCraigCmehil)
HiCraig,
JustcheckedthatthisweblogofyoursispostedinSDN(topic).Probablyitshould
beinBSP.
Regards,
SubramanianV.
Like(0)
CraigCmehilNov15,20041:32AM(inresponsetoSubramanianVenkateswaran)
It'sactuallyinABAP,BSP,SDNandTechnology
Like(0)
SubramanianVenkateswaranNov15,20041:35AM(inresponseto
CraigCmehil)
Sorryaboutthat...guessIdidn'tlookproperly.
Regards,
SubramanianV.
Like(0)
JonathanBourneNov15,20043:33AM
VeryinterestingarticleandI'mlookingforwardtogivingitatryonceI'veappliedSP'stoWebAS6.20
(incidentally,thatisalsoagreatarticleCraig).
JustwantedtomentionthatratherthanhuntingfortheSmartformsfunctionmodulenamethe
followingfunctionmodulecanbeused:
SSF_FUNCTION_MODULE_NAME
ThisFMtakestheSmartformnameandreturnsthefunctionmodulename.Thisisamorerobust
solutionastheSmartformmayreceiveadifferentFMnamewhenitistransportedtoothersystems.
Thanksagainforagreatarticle.
JB
Like(0)
CraigCmehilNov15,20046:23AM(inresponsetoJonathanBourne)
Goodtip!I'llhavetoupdatetheweblogtomentionthataswell!
Like(0)
MarkFinnernNov15,20047:40PM
HiCraig&Co,
ThisisanexcellentpostthatshowsthecollectivepowerofSDN.
Verynice,Mark.
Like(0)
MercedesBenzSouthAfricaNov19,200410:27PM
Histuffguys!!
I'mveryfamiliarwithgettingPDF'sandExcelontoourSupplierPortal...greattoseewearefollowing
thesameprocess!!Werecentlyput"EBPPurchaseOrderDisplay"viaPDFintoaBSPontheSAP
Portal...GREATtoseeyouguysusingafunctionmoduleIhaven'tusedyet
(CONVERT_ABAPSPOOLJOB_2_PDF),I'vealwaysusedthe"convertOTF"andthengetthatinto
PDFtogetittowork...ImustsaythemakingaCOMPLEXSmartFormisthe"bottleneck"inthe
process...IhopeSAPgetSmartFormstothelevelofeaseascreatingadocumentusingCrystal
http://scn.sap.com/people/craig.cmehil/blog/2004/11/10/bsphowtogeneratepdfoutputfromabsp 8/15
29/7/2015 BSP/HowTo:GeneratePDFOutputfromaBSP.|SCN
Reports(forexample)oneday!!
Butonceagaingreatworkguys!!
LyntonGrice
Like(0)
MercedesBenzSouthAfricaNov19,200410:32PM(inresponsetoMercedesBenzSouthAfrica)
"Histuffguys!!"MANIneedtoconcentratemore!!Thatwasmeanttobe"GREATstuff
guys!!"...doesn'tlookperfectatfirst.....sorryboutthat:)
Lynton
Like(0)
CraigCmehilNov20,200412:59AM(inresponsetoMercedesBenzSouthAfrica)
Greattoreceivefeedbackfromothersdoinguingtheweblogsasreference,soistheABAP
toSpoolworkngbetterforyouthen??
Like(0)
MercedesBenzSouthAfricaNov22,200411:06AM(inresponsetoCraigCmehil)
Haven'tusedityetBUTIhavetorewritethe"RFQ"display+downloadIdidin
JavaintoBSP...I'llgiveitabachwhenIneedtocalltheRFQSmartForm.Bythe
waythereisalittleproblemI'mhavingandwouldLOVEaWeblogonit...howcan
someoneuploadaZIPfile(Excelfilezipped...)andthenweusea"ZIPclass"in
ABAPtounzipthefileontheserver,takeouttheExcelfileandpumpthedatainto
SAP.I'vedoneiteasilyinJavaBUTnowneedtodoitinBSP...Ihaveanidea,just
wantedtoknowwhatyourthoughtsare(wehaveaSupplierPortalandthissortof
thingisNBoverSLOWlines!!)
Regards
Lynton
Like(0)
CraigCmehilNov22,20041:41PM(inresponsetoMercedesBenzSouthAfrica)
PopoverintotheBSPforumandstartatopic,whatwegenerate
someoneormyselfcanwriteupaweblogonit:)
Like(0)
JayeshShahFeb28,20051:13AM(inresponsetoMercedesBenzSouthAfrica)
Hi,
Needhelpwiththefollowingquestions.
Hi,
1)WewanttoshowsomedetailsinaniViewpertainingtothepersonwhohasloggedinto
theportal.Wearecallingafunctionmodule(whenauserclicksonaworksetintheportal)
andpassingsomeparameterstoit.Thefunctionmodulepullsthedatafromthetablesand
generatesasapscriptwhichdisplaysthedatainaSAPScriptForm.
NowourproblemishowdowedisplaytheformintheiView?
2)WewanttoshowsomedetailsinaniViewpertainingtothepersonwhohasloggedinto
theportal.Wearecallingafunctionmodule(whenauserclicksonaworksetintheportal)
andpassingsomeparameterstoit.Thefunctionmodulepullsthedatafromthetablesand
convertsthedataintoapdffile.
Howdowedisplaythedatainthe.pdfformatintheiView.
Thanksinadvance
Like(0)
CraigCmehilFeb28,20051:20AM(inresponsetoJayeshShah)
You'llneedtotakealookat BSPProgramming:HandlingOfNonHTML
DocumentsinordertoseehowtodisplayNONHTMLdocuments.Thatweblogwill
answeryourquestionperfectly.
Like(0)
JayeshShahMar1,20053:21AM(inresponsetoCraigCmehil)
IhaveaWebDynproapplicationwhichwillcallanR/3RFCthatreturnsa
PDFfile.
http://scn.sap.com/people/craig.cmehil/blog/2004/11/10/bsphowtogeneratepdfoutputfromabsp 9/15
29/7/2015 BSP/HowTo:GeneratePDFOutputfromaBSP.|SCN
1)Isitpossibletopassparametersdynamically(Foreguseridofthe
personwhohasloggedontotheportal)fromwebdynprotoaRFC?Ifyes,
how?
Thanksinadvance.
Jayesh
Like(0)
CraigCmehilMar1,20053:47AM(inresponsetoJayeshShah)
PleasepostyourquestionsintheproperForum(eitherBSPor
PortalorWebDynpro)
Like(0)
BrantBergJan3,200510:13AM
Greatarticle.
Iwasabletouseyourcode(withminorchanges)toconvertmailformstoPDF.YoucanuseFM
MAIL_FUNCTION_MODULE_NAMEtogetthemailformfunctionmodulename,andsubstitutethatin
the'callfunction'ofOnInputProcessing
Thanks,yousavedmetonsofwork!
BrantBerg
Like(0)
GreetsonShunmugasundaramMar1,20052:42PM
HiAll,
IsthesamecodewillworkinMVCConcept????
Ifyeswhereweneedtowriteallthecode??
isitintheDO_HANDLE_EVENTorintheViewpage??
ExpectingthereplyASAP.
Thanks,
Greetson
Like(0)
CraigCmehilMar1,200511:37PM(inresponsetoGreetsonShunmugasundaram)
FirstoffyoucanexpectanythingyouwantASAPbuttherealityofitisthatyouprobably
won'tgetit.Imeanthisisn'tasupportdeskandweareallherejusttryingtohelpeachother
out.
Asforthiscode,yesitworksfineinMVCandwhereyouwriteitalldependsonyouandyour
application.
IfyouhavespecificquestionstakeajumpovertotheBSPforum,it'samuchbetterplacefor
helpingeachotherout.
Like(0)
StephanWestmarkApr6,200510:11AM
Greatarticle.Thankyou.
Still,I'mwonderingwhichtableyouuseforzsystems.
data:lt_systypetableofzsystems.
Icannotfindthistable.Wouldyoupleasetellmetheorigin?
Andwhichtabledoyouuseforzsystemtab?Thistableisreferencedwithinthesmartform
Thankyouverymuchforyourhelp,
Stephan
Like(0)
CraigCmehilApr6,200510:40AM(inresponsetoStephanWestmark)
SorryaboutthattheZindicatesacustomercreatedobject.SointhiscaseZSYSTEMSisa
tableIcreatedthatcontainsbasicsysteminfo,wehaveover100systems.ZSYSTEMTABis
a"tabletype"definedwiththelinetypeZSYSTEMS.
Craig
Like(0)
JoseManuelCalaLopezJan24,20068:05AM
http://scn.sap.com/people/craig.cmehil/blog/2004/11/10/bsphowtogeneratepdfoutputfromabsp 10/15
29/7/2015 BSP/HowTo:GeneratePDFOutputfromaBSP.|SCN
IhavetriedtoconvertanABAPlistwithFMCONVERT_ABAPSPOOLJOB_2_PDF,butitdoesn'twork.
TheproblemistheconversionoftableoftypetlinereturnsbytheFMtoaxstring.Ihavetriedall
solutionsinthisweblogandintheBSPforum,butanythingworks.
Idothetestina6.40UNICODEsystem.
Finally,Ifindacodetodotheconversion:
data:spool_nrtypeTSP01RQIDENT,
linetypetline,
l_pdf_xstringtypexstring,
lt_linestypetableoftline,
l_pdf_lentypei.
fieldsymbols
typeX.
...codetoobtainthespool_nr...
CALLFUNCTION'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID=spool_nr
NO_DIALOG=''
IMPORTING
PDF_BYTECOUNT=l_pdf_len
TABLES
PDF=lt_lines
EXCEPTIONS
ERR_NO_ABAP_SPOOLJOB=1
ERR_NO_SPOOLJOB=2
ERR_NO_PERMISSION=3
ERR_CONV_NOT_POSSIBLE=4
ERR_BAD_DESTDEVICE=5
USER_CANCELLED=6
ERR_SPOOLERROR=7
ERR_TEMSEERROR=8
ERR_BTCJOB_OPEN_FAILED=9
ERR_BTCJOB_SUBMIT_FAILED=10
ERR_BTCJOB_CLOSE_FAILED=11
OTHERS=12
.
clearl_pdf_xstring.
loopatlt_linesintoline.
assignlineto
castingtypeX.
concatenatel_pdf_xstring
intol_pdf_xstringinbytemode.
endloop.
l_pdf_len=xstrlen(l_pdf_xstring).
...codetomakecached_response...
Like(0)
JoseManuelCalaLopezJan24,20068:16AM(inresponsetoJoseManuelCalaLopez)
Problemswiththehtmlformating.Codeisas:
data:spool_nrtypeTSP01RQIDENT,
linetypetline,
l_pdf_xstringtypexstring,
lt_linestypetableoftline,
l_pdf_lentypei.
fieldsymbols
typeX.
...codetoobtainthespool_nr...
CALLFUNCTION'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID=spool_nr
NO_DIALOG=''
IMPORTING
PDF_BYTECOUNT=l_pdf_len
TABLES
PDF=lt_lines
EXCEPTIONS
ERR_NO_ABAP_SPOOLJOB=1
ERR_NO_SPOOLJOB=2
ERR_NO_PERMISSION=3
ERR_CONV_NOT_POSSIBLE=4
ERR_BAD_DESTDEVICE=5
USER_CANCELLED=6
ERR_SPOOLERROR=7
ERR_TEMSEERROR=8
ERR_BTCJOB_OPEN_FAILED=9
ERR_BTCJOB_SUBMIT_FAILED=10
http://scn.sap.com/people/craig.cmehil/blog/2004/11/10/bsphowtogeneratepdfoutputfromabsp 11/15
29/7/2015 BSP/HowTo:GeneratePDFOutputfromaBSP.|SCN
ERR_BTCJOB_CLOSE_FAILED=11
OTHERS=12
.
clearl_pdf_xstring.
loopatlt_linesintoline.
assignlineto
castingtypeX.
concatenatel_pdf_xstringintol_pdf_xstring
inbytemode.
endloop.
l_pdf_len=xstrlen(l_pdf_xstring).
...codetomakecached_response...
Like(0)
CommunityUserJan26,20061:34AM(inresponsetoJoseManuelCalaLopez)
Sorry,thiswasalltriedlongbefore6.40,butitseemstoyouhaveaddedthepieces
tomakeitworkgreatjob!
Like(0)
CommunityUserJul7,20067:18AM
Thetablecontained(nolongerhaveit)justtheSIDofthesystemandthename(desc)ofthesystem
notreallyanythingmuch.
Thiswasalsoona620system.Butyoucanreallyuseanytables.
Like(0)
AnubhavJainJun2,200712:01AM
Ihaveusedmysmartform:zdpbirandtable:zdpbarandthegeneratedFMforsmartformis
'/1BCDWB/SF00000571',butwheniexecutetheBSPApplicationitthrowsthefollowingerror:
SAPNote
Thefollowingerrortextwasprocessedinthesystem:
AnexceptionwiththetypeCX_SY_DYN_CALL_PARAM_MISSINGoccurred,butwasneither
handledlocally,nordeclaredinaRAISINGclause
ExceptionClassCX_SY_DYN_CALL_PARAM_MISSING
ErrorName
ProgramCL_O20Q0EUR89BCFKJ1CHWU5YVP65JCP
IncludeCL_O20Q0EUR89BCFKJ1CHWU5YVP65JCM005
ABAPClassCL_O20Q0EUR89BCFKJ1CHWU5YVP65J
Method_ONINPUTPROCESSING
BSPApplicationZANU_PDF_OUTPUT
BSPPageFIRST.HTM
Line99
LongtextThecallofthefunction/1BCDWB/SF00000571failed:therequiredparameter
WA_ZDPBIRwasnotfilled.
Whatisthereasonandpossiblesolution?
Regards,
AnubhavJain.
Like(0)
Jun13,20082:24AM
Hallo
IwanttoconvertasmartformdocumentintopdfinmyBSPApplikation.
Butwhenithavetoconvert,igotthemessage"Datadidntbeginswith'%pdf'"inthepdfreade.Idont
knowwhy???
HereismyCodefromtheIntializationEvent:
*eventhandlerfordataretrieval
*parametersforgeneratedfunctionmodule
data:l_function_module_nametypers38l_fnam,
ls_output_optionstypessfcompop,
ls_control_parameterstypessfctrlop,
ls_output_datatypessfcrescl,
l_devtypetyperspoptype.
*generatedresult:HTMLwithembeddedCSS
http://scn.sap.com/people/craig.cmehil/blog/2004/11/10/bsphowtogeneratepdfoutputfromabsp 12/15
29/7/2015 BSP/HowTo:GeneratePDFOutputfromaBSP.|SCN
data:ls_xmloutputtypessfxmlout,
lt_html_rawtypetsfixml,
l_xstringtypexstring,"neededforHTTPresponse
l_html_xstringtypexstring,
l_xlengthtypei.
*generatedresult:PDFformat
data:l_pdf_xstringtypexstring,
lt_linestypetableoftline,
ls_linetypetline,
l_pdf_lentypei.
*CookiemitEingabewertenholen
cl_bsp_server_side_cookie=>get_server_cookie(
EXPORTING
name='lt_fields'
application_namespace='NONE'
application_name='NONE'
username='NONE'
session_id='NONE'
data_name='NONE'
"IMPORTING
"expiry_date=date
"expiry_time=time
CHANGING
data_value=lt_fields).
*CookiemitEquipmentdatenholen
cl_bsp_server_side_cookie=>get_server_cookie(
EXPORTING
name='ums_equip_ges'
application_namespace='NONE'
application_name='NONE'
username='NONE'
session_id='NONE'
data_name='NONE'
"IMPORTING
"expiry_date=date
"expiry_time=time
CHANGING
data_value=ums_equip).
*
*Getnameofgeneratedfunctionmodule
*
callfunction'SSF_FUNCTION_MODULE_NAME'
exportingformname='Z_REPKOST_GES'
*variant=''
*direct_call=''
importingfm_name=l_function_module_name
exceptionsno_form=1
no_function_module=2
others=3.
ifsysubrc0.
*errorhandling
messageidsymsgidtypesymsgtynumbersymsgno
withsymsgv1symsgv2symsgv3symsgv4.
exit.
endif.
*
*getdevicetypefromlanguage
*
callfunction'SSF_GET_DEVICE_TYPE'
exporting
i_language=sylangu
*i_application='SAPDEFAULT'
importing
e_devtype=l_devtype
exceptions
no_language=1
language_not_installed=2
no_devtype_found=3
system_error=4
others=5.
ifsysubrc0.
*errorhandling
messageidsymsgidtypesymsgtynumbersymsgno
withsymsgv1symsgv2symsgv3symsgv4.
endif.
*setdevicetypeinoutputoptions
ls_output_optionstdprinter=l_devtype.
http://scn.sap.com/people/craig.cmehil/blog/2004/11/10/bsphowtogeneratepdfoutputfromabsp 13/15
29/7/2015 BSP/HowTo:GeneratePDFOutputfromaBSP.|SCN
*
*Callthegeneratedfunctionmodule
*
callfunctionl_function_module_name
exporting
*archive_index=
*archive_parameters=
control_parameters=ls_control_parameters
*mail_appl_obj=
*mail_recipient=
*mail_sender=
output_options=ls_output_options
user_settings=space
UMS_EQUIP=UMS_EQUIP
LT_FIELDS=LT_FIELDS
importing
*document_output_info=
job_output_info=ls_output_data
*job_output_options=
*tables
*zsystems=lt_sys
exceptionsformatting_error=1
internal_error=2
send_error=3
user_canceled=4
others=5.
ifsysubrc0.
*errorhandling
messageidsymsgidtypesymsgtynumbersymsgno
withsymsgv1symsgv2symsgv3symsgv4.
endif.
*
*ConversionofoutputformatOTFintoPDFformat
*
*nowconvertthefinaldocument(OTFformat)intoPDFformat
callfunction'CONVERT_OTF'
exporting
format='PDF'
*MAX_LINEWIDTH=132
*ARCHIVE_INDEX=''
*COPYNUMBER=0
importing
bin_filesize=l_pdf_len
bin_file=l_pdf_xstring"binaryfile
tables
otf=ls_output_dataotfdata
lines=lt_lines
exceptions
err_max_linewidth=1
err_format=2
err_conv_not_possible=3
err_bad_otf=4
others=5
.
ifsysubrc0.
*errorhandling
messageidsymsgidtypesymsgtynumbersymsgno
withsymsgv1symsgv2symsgv3symsgv4.
endif.
DATA:cached_responseTYPEREFTOif_http_response.
DATA:guidTYPEguid_32.
DATA:fileUploadTYPEREFTOCL_HTMLB_FILEUPLOAD.
ifsysubrcEQ0.
CREATEOBJECTcached_responseTYPECL_HTTP_RESPONSEEXPORTINGadd_c_msg=1.
l_pdf_len=xstrlen(l_pdf_xstring).
cached_response>set_data(data=l_pdf_xstring
length=l_pdf_len).
cached_response>set_header_field(name=if_http_header_fields=>content_type
value='application/pdf').
cached_response>set_status(code=200reason='OK').
cached_response>server_cache_expire_rel(expires_rel=180).
CALLFUNCTION'GUID_CREATE'
IMPORTING
ev_guid_32=guid.
CONCATENATEruntime>application_url'/'guid'.pdf'INTOdisplay_url.
cl_http_server=>server_cache_upload(url=display_url
response=cached_response).
http://scn.sap.com/people/craig.cmehil/blog/2004/11/10/bsphowtogeneratepdfoutputfromabsp 14/15
29/7/2015 BSP/HowTo:GeneratePDFOutputfromaBSP.|SCN
ENDIF.
RETURN.
Ihopeyoucanhelpme.
KindRegards
Like(0)
AbhishekPeriwalDec22,200810:21PM
HiCraig,
Iamhavingsomeproblemingeneratingthecachedresponse.Iamwritingmycodeinamethodofa
classwhichistriggeredfromWebUI.Theobjectruntimeisnotdefinedheresoitthrowsanerroreach
time.PleaseletmeknowhowshouldIproceed.
Thanks,
Abhishek
Like(0)
CommunityUserJan6,20097:11PM(inresponsetoAbhishekPeriwal)
Irecommendyouposttotheforums,beeasiertotroubleshoottherethanhere.
Like(0)
PraveenBitlingMar14,201111:41PM
Thanksfortheblog.
Like(0)
AntonWenzelhuemerOct9,20122:19PM
toobadthatthisblogisnearlyunreadable.itwouldstillbeveryusefultodayandiscitedonsome
pecialinterestpages.
goodjobdonelongtimeago.andnowbacktothefuture:)
Like(0)
OxanaNoaZubarevOct15,201211:06AM(inresponsetoAntonWenzelhuemer)
HiAnton,
Thisblogwassubmittedinthe ReportYourMissingBlogContentdocumentandyou
maytracktheprocessviathisdocument.Thecontentwillberepairedshortly.
Thanks,
Oxana
Like(0)
Addacomment
http://scn.sap.com/people/craig.cmehil/blog/2004/11/10/bsphowtogeneratepdfoutputfromabsp 15/15