Calling a subroutine from SAP SCRIPT form .

In order to call a subroutine program from a SAP Script you have to do 2 things :

1 – write your subroutine which will take values from the script and doing some calculations on them or use them to retrieve another set of values.

2- Calling the subroutine from the SAP Script in order to Pass some values and get newly calculated one.

Here’s an overview to let you know how to write a subroutine and how to call it from your Script …. Enjoy!

** First write your subroutine **

1-      Go to se38

2-      Create a program with type “ subroutine pool “

3-      Add your form in  the subroutine program :

Form (Form_Name) TABLES in_tab  STRUCTURE  itcsy

out_tab STRUCTURE  itcsy.

ENDFORM.

4- Read Values passed from the script to the Subroutine by writing the following code :

READ TABLE  in_tab  WITH KEY  ‘ Type your value name here ‘. “Read Data into internal table (in_tab)

CHECK sy-subrc = 0. “Check if  the record was read successfully.

(your variable name) = in_tab-value. “Take the value from the internal table into a variable

5- Passing Newly calculated values back to the Script by writing the following code :

READ TABLE out_tab WITH KEY ‘ Type your output value in CAPITAL LETTERS ONLY HERE‘. ” Output Parameter”

CHECK sy-subrc = 0. Check if the data was read successfully “

out_tab-value = Your Calculated Value Parameter .

MODIFY out_tab INDEX sy-tabix . ” Passing the values again to the sap script to be displayed

Here’s a demonstrating example to show you how to use the previous code :

Form Calc TABLES in_tab  STRUCTURE  itcsy

out_tab STRUCTURE  itcsy.

READ TABLE  in_tab  WITH KEY  ‘KOMVD_KWERT‘. “Input Parameter”

CHECK sy-subrc = 0.

KOMVD_KWERT_VAR= in_tab-value.

KOMVD_KWERT_VAR = KOMVD_KWERT_VAR  *  1000 / 93889. ” Any desired calculations

READ TABLE out_tab WITH KEY ‘RESULT.” Output Parameter”

CHECK sy-subrc = 0. ” If sy-subrc = 0 then data was read successfully

out_tab-value = KOMVD_KWERT_VAR

MODIFY out_tab INDEX sy-tabix .

ENDFORM.

*********————————————————–*********

** Second calling the Subroutine from the SAP Script **

by opening your SAP Script, right click on the main window then choose edit text and add the following code :

/: PERFORM Form_Name in Subroutine_Name

/: USING &INPUT_PARAMETER&

/: CHANGING &OUTPUT_PARAMETER&

/: ENDPERFORM

Example :

/:     PERFORM Calc IN PROGRAM  Z_Test

/:      USING &KOMVD_KWERT&

/:      CHANGING &RESULT&

/:      ENDPERFORM

or you can define  your parameters first instead of using its technical names directly as follows:

/E    Calc_Line  ” Code Name

/:     DEFINE &INPUT& = &KOMVD-KWERT& “Passing Value from the script to the input parameter in the  program

/:     DEFINE &RESULT& ” Output Parameter key

/:     PERFORM Calc IN PROGRAM (Prog_Name)

/:      USING &INPUT& “Input Parameter”

/:      CHANGING &RESULT& ” Output Parameter”

/:      ENDPERFORM


Advertisements

36 thoughts on “Calling a subroutine from SAP SCRIPT form .

  1. sales techniques February 1, 2013 / 9:01 AM

    Hi there! Someone in my Myspace group shared this site with us so I came
    to give it a look. I’m definitely enjoying the information. I’m bookmarking and will be tweeting this to my followers!
    Exceptional blog and brilliant design and style.

    Like

    • menoshet February 5, 2013 / 8:20 AM

      Thanks a lot Jeremy for your sweet words 🙂

      Sara

      Like

  2. Rosemary February 22, 2013 / 5:52 PM

    I am sure this piece of writing has touched all the internet people, its really really pleasant piece of
    writing on building up new blog.

    Like

  3. green smoke promo code April 17, 2013 / 11:38 AM

    Interesting help as well as links. I’ve found a few things i think will continue to work. awsome job!!!!

    Like

  4. borvest inkral June 14, 2017 / 1:52 PM

    I have been examinating out some of your posts and i can claim nice stuff. I will make sure to bookmark your blog.

    Like

  5. borvestinkral June 19, 2017 / 2:47 PM

    you’re really a good webmaster. The web site loading speed is amazing. It seems that you’re doing any unique trick. In addition, The contents are masterpiece. you have done a fantastic job on this topic!

    Like

  6. world news June 21, 2017 / 8:52 AM

    Hi! Do you use Twitter? I’d like to follow you if that would be okay. I’m undoubtedly enjoying your blog and look forward to new posts.

    Like

    • menoshet June 21, 2017 / 11:15 AM

      Hi
      Sorry i dont use twitter

      Like

  7. auf wirtschaft.com June 21, 2017 / 5:50 PM

    I do trust all the ideas you’ve presented on your post. They are really convincing and will certainly work. Still, the posts are very short for newbies. May just you please extend them a little from subsequent time? Thank you for the post.

    Like

  8. Bola88 Online June 24, 2017 / 8:05 AM

    I got what you intend,bookmarked, very nice internet site.

    Like

  9. Dewapoker June 24, 2017 / 1:07 PM

    Saved as a favorite, I really like your blog!

    Like

  10. led pANEL dECKENLEUCHTE June 24, 2017 / 7:02 PM

    Thank you, I’ve recently been searching for information about this subject for ages and yours is the best I have found out so far. But, what in regards to the bottom line? Are you certain in regards to the source?

    Like

  11. singapore lifestyle blog June 24, 2017 / 11:12 PM

    I do not even understand how I stopped up here, but I believed this submit was great. I do not recognize who you are but certainly you are going to a famous blogger if you happen to aren’t already 😉 Cheers!

    Like

  12. CBD vape liquid June 25, 2017 / 2:55 AM

    you’re really a good webmaster. The web site loading speed is incredible. It seems that you’re doing any unique trick. Also, The contents are masterwork. you’ve done a great job on this topic!

    Like

  13. Esurance auto insurance quotes June 25, 2017 / 11:19 PM

    Thanks for another informative blog. Where else could I get that kind of information written in such an ideal way? I’ve a project that I’m just now working on, and I’ve been on the look out for such info.

    Like

  14. nintendo switch June 26, 2017 / 3:14 AM

    I simply needed to thank you very much all over again. I’m not certain the things that I could possibly have sorted out without the entire ways shown by you about that problem. It had been a hard matter for me personally, but encountering this professional approach you processed that forced me to cry over fulfillment. Now i’m happier for the assistance and as well , trust you really know what a great job you happen to be putting in instructing the mediocre ones all through your web site. I am sure you have never come across any of us.

    Like

  15. nationwide auto insurance June 27, 2017 / 1:13 AM

    Wow, superb blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your website is magnificent, as well as the content!

    Like

  16. Fonds für Gründer June 27, 2017 / 3:41 PM

    of course like your web site but you have to check the spelling on several of your posts. Several of them are rife with spelling problems and I find it very bothersome to tell the truth nevertheless I will certainly come back again.

    Like

  17. self catering accommodation in Mombasa June 28, 2017 / 12:19 AM

    Thank you for sharing superb informations. Your website is very cool. I’m impressed by the details that you have on this website. It reveals how nicely you understand this subject. Bookmarked this website page, will come back for extra articles. You, my friend, ROCK! I found simply the info I already searched all over the place and just couldn’t come across. What a great web site.

    Like

  18. where to stay June 28, 2017 / 8:51 AM

    F*ckin’ amazing issues here. I am very satisfied to look your article. Thanks so much and i’m looking ahead to contact you. Will you kindly drop me a mail?

    Like

  19. accommodation in Arusha June 28, 2017 / 6:02 PM

    Hello there! Would you mind if I share your blog with my facebook group? There’s a lot of people that I think would really enjoy your content. Please let me know. Thank you

    Like

  20. guest house Windhoek June 28, 2017 / 10:29 PM

    I went over this website and I think you have a lot of fantastic info, saved to bookmarks (:.

    Like

  21. full version pc games download June 29, 2017 / 10:52 PM

    Very fantastic info can be found on web site. “The American temptation is to believe that foreign policy is a subdivision of psychiatry.” by Robert Francis Kennedy.

    Like

  22. mirror with lights July 1, 2017 / 3:05 PM

    Awsome article and straight to the point. I am not sure if this is in fact the best place to ask but do you people have any thoughts on where to employ some professional writers? Thx 🙂

    Like

  23. mr coffee espresso maker parts July 1, 2017 / 8:06 PM

    Thank you for another informative website. The place else may just I am getting that type of information written in such a perfect method? I have a venture that I am just now operating on, and I have been on the look out for such info.

    Like

  24. State farm life insurance July 2, 2017 / 1:21 AM

    Hey there, You’ve done an incredible job. I will definitely digg it and individually suggest to my friends. I’m confident they will be benefited from this website.

    Like

  25. homepage July 22, 2017 / 8:45 AM

    Wonderful post but I was wondering if you could write a litte more on this subject? I’d be very thankful if you could elaborate a little bit further. Cheers!

    Like

  26. ig August 1, 2017 / 9:26 PM

    I’ve been surfing online more than 3 hours today, yet I never found any interesting article
    like yours. It is pretty worth enough for me.
    In my view, if all website owners and bloggers made good content as you did, the web will be much more useful than ever before.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s