Saturday, 15 November 2014

SCRIPT: How to Use conditional statements in SAPscripts



Step1. Here we have the sap script output of same form for two different billing document. In the highlighted we can observe that depending upon the different billing type , the text appears as INVOICE or DEBIT MEMO or some thing else. This decision is controlled within the script by the uses of some conditional statements like if..else or switch case.
















Step2 . go to VBRK table in SE11 and go to the domain of the field - VBTYP.

















Step3. So we have different domain fixed values.



















Step4. Go to the Script and open the windows tab. Here we will add a variable window to show our invoice types, because MAIN window will flow to multiple pages depending its content but VAR window will remain on the single page only with variable content. Go to the EDIT menu.














Step5 . Click on Create Element.













Step6. Give a window name and description and continue.



















Step7 . So one more window INFO of VAR type is added. Go to Page Windows tab.













Step8. Go to the Edit menu.














Step9. Select Create Element.















Step10. From the POPUP, Double click on the INFO window.

























Step11. So it is added to the page Windows.  Select its dimensions. Go to adding the Text Elements.




Step12. Add some conditional statements here- here it is switch case( if.. elseif...endif can be another alternative). LS_BILL - is a place holder which will be passed from the driver program to the script at runtime.



















Step13. Here we have the program which reads a billing doc and call the script.



















Step14. Here some of the billing docs with different VBTYP.










Step15. Run the program and provide a billing doc number.












Step16. So here is teh output in VAR window as Invoice.


















Step17. Run the Program with different billing doc and with different vbtyp.










Step18. Here is the O/P.














--------------------------------------------------------------------------------------

No comments:

Comments system

Disqus Shortname