{"id":7833,"date":"2025-09-13T01:35:50","date_gmt":"2025-09-12T20:05:50","guid":{"rendered":"https:\/\/www.sapewmhelp.com\/?question=sap-script-sales-order-confirmation"},"modified":"2025-09-13T01:35:50","modified_gmt":"2025-09-12T20:05:50","slug":"sap-script-sales-order-confirmation","status":"publish","type":"question","link":"https:\/\/www.sapewmhelp.com\/?question=sap-script-sales-order-confirmation","title":{"rendered":"SAP SCRIPT : Sales Order Confirmation"},"content":{"rendered":"<p>A company wants to generate a <strong>Sales Order Confirmation<\/strong> that prints both <strong>header data<\/strong> (from VBAK: Sales Order Number, Customer, Date) and <strong>item details<\/strong> (from VBAP: Material, Description, Quantity).<br \/>The business expects a simple <strong>printable document<\/strong> that can be given to customers.<\/p>\n<p>Since this is a text-heavy output with minimal graphics, the customer chooses <strong>SAPscript<\/strong> as the form technology.<\/p>\n<\/p>\n<p>ABAP Driver Program \u2192 Fetch data (VBAK\/VBAP)<br \/>\n\u2193<br \/>\nSAPscript Layout Set (SE71) \u2192 Windows + Paragraph Formats<br \/>\n\u2193<br \/>\nFunctions: OPEN_FORM \u2192 WRITE_FORM \u2192 CLOSE_FORM<br \/>\n\u2193<br \/>\nFinal Output \u2192 Printed \/ Spool \/ PDF<\/p>\n<\/p>\n<p>REPORT zsd_sapscript_driver.<\/p>\n<p>TABLES: vbak, vbap.<\/p>\n<p>DATA: it_vbak TYPE vbak,<br \/>\nit_vbap TYPE TABLE OF vbap,<br \/>\nwa_vbap TYPE vbap.<\/p>\n<p>PARAMETERS: p_vbeln TYPE vbak-vbeln OBLIGATORY.<\/p>\n<p>START-OF-SELECTION.<\/p>\n<p>&#8220;Fetch Sales Order Header<br \/>\nSELECT SINGLE * INTO it_vbak<br \/>\nFROM vbak<br \/>\nWHERE vbeln = p_vbeln.<\/p>\n<p>IF sy-subrc &lt;&gt; 0.<br \/>\nMESSAGE &#8216;Sales Order not found&#8217; TYPE &#8216;E&#8217;.<br \/>\nENDIF.<\/p>\n<p>&#8220;Fetch Sales Order Items<br \/>\nSELECT * INTO TABLE it_vbap<br \/>\nFROM vbap<br \/>\nWHERE vbeln = p_vbeln.<\/p>\n<p>&#8220;Open Form<br \/>\nCALL FUNCTION &#8216;OPEN_FORM&#8217;<br \/>\nEXPORTING<br \/>\nform = &#8216;ZSALES_ORDER&#8217; &#8221; SAPscript layout set<br \/>\nlanguage = sy-langu.<\/p>\n<p>&#8220;Print Header Window<br \/>\nCALL FUNCTION &#8216;WRITE_FORM&#8217;<br \/>\nEXPORTING<br \/>\nelement = &#8216;HEADER&#8217; &#8221; SAPscript text element<br \/>\nTABLES<br \/>\nlines = it_vbak.<\/p>\n<p>&#8220;Print Items<br \/>\nLOOP AT it_vbap INTO wa_vbap.<br \/>\nCALL FUNCTION &#8216;WRITE_FORM&#8217;<br \/>\nEXPORTING<br \/>\nelement = &#8216;ITEMS&#8217;<br \/>\nTABLES<br \/>\nlines = wa_vbap.<br \/>\nENDLOOP.<\/p>\n<p>&#8220;Close Form<br \/>\nCALL FUNCTION &#8216;CLOSE_FORM&#8217;.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Key Notes<\/strong><\/p>\n<ul>\n<li>\n<p>Layout set is created in <strong>SE71<\/strong> (e.g., <code>ZSALES_ORDER<\/code>).<\/p>\n<\/li>\n<li>\n<p>Text elements <strong>HEADER<\/strong> and <strong>ITEMS<\/strong> must be defined inside the layout set.<\/p>\n<\/li>\n<li>\n<p>Data (from VBAK\/VBAP) flows from ABAP \u2192 WRITE_FORM \u2192 Windows in layout.<\/p>\n<\/li>\n<\/ul>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","question-category":[158],"question_tags":[178,283,177,418],"class_list":["post-7833","question","type-question","status-publish","hentry","question-category-abap","question_tags-abap","question_tags-forms","question_tags-sap","question_tags-sapscript"],"_links":{"self":[{"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=\/wp\/v2\/question\/7833","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=\/wp\/v2\/question"}],"about":[{"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7833"}],"wp:attachment":[{"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7833"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fquestion-category&post=7833"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fquestion_tags&post=7833"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}