Skip to Content
author's profile photo Former Member
Former Member

how to multiply two values in form itself.

Hi guru,

in my form i had written like this two values which are coming in my out put of the script.This two value coming direct from table

RESBD and GPREIS.

= ,, &RESBD-MENGE(C)& </> <B2>&RESBD-GPREIS&

now the requirement is two multiply this two values ex. 55 and 5 suppose and disply the final vaue in the output .

how to achieve it in form itself.

please somebody suggest me.

thanks

latalata

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Aug 13, 2009 at 03:37 PM

    You would have to do a PERFORM from within the SAPscript layout set to multiply the two values.

    However, isn't the extended value in RESBD-GPREIS_2 ?

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 13, 2009 at 05:40 PM

    Hi Friend,

    If u want to multiply any two values in a smartform and result u want to print in a smartform,

    then just above the node where you are printing the value i.e just above the text node where u r printing the value,

    insert a "Program Line" under Flow Logic.

    input both the both the fields u want to multiply and also the field in which u want to store the calculated value , in the created "program line".

    output the calculated value from program line and use it in the text node just below it.

    This will definately resolve ur issue

    Regards,

    Akash Rana

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      I can suggest you 2 ways of doing it.

      1. Follow the suggestion of Norman Salter.

      2. Just before you wanted to print the multiplied value of the 2 fields, just created a perform statement like this.

      PERFORM Multilply_filelds IN PROGRAM ZXX

      USING &A&

      USING &B&

      CHANGING &C&

      ENDPERFORM

      Then print &C&

      here A and B are the fields u need to multiply. C is the variable to hold the multiplied value.

      ZXX - is a program in which u can write the calculation part.

      Check some of the sap scripts and follow the same method to do it.

      Let me know if you need any help.

  • author's profile photo Former Member
    Former Member
    Posted on Aug 14, 2009 at 08:26 AM

    Hi,

    Call a PERFORM in ur form with 2 Using paramters (&RESBD-MENGE(C)&, &RESBD-GPREIS&) and use another changing parameter to get the value after multiplying above two. Define this PERFORM in driver program.

    Eg:

    In Script:

    DEFINE : &tot_value&

    PERFORM z_total_value IN PROGRAM z_cal_total USING &RESBD-MENGE& &RESBD-GPREIS&

    changing &tot_value&

    In Program z_cal_total:

    FORM z_total_value using in_tab structure itcsy

    changing out_tab structure itcsy.

    data : lv_menge TYPE resbd-menge,

    lv_gpreis TYPE resbd-gpreis,

    lv_total TYPE resbd-menge.

    READ table in_tab with KEY name = 'RESBD-MENGE'.

    IF sy-subrc EQ 0

    lv_menge = in_tab-value.

    ENDIF.

    READ table in_tab with KEY name = 'RESBD-GPREIS'.

    IF sy-subrc EQ 0

    lv_gpreis = in_tab-value.

    ENDIF.

    READ table out_tab with KEY name = 'TOT_VLAUE'.

    IF sy-subrc EQ 0.

    lv_total = lv_menge * lv_gperis.

    out_tab-value = lv_total.

    MODIFY out_tab transporting fields value.

    ENDIF.

    ENDFORM.

    Hope it helps!!

    Rgds,

    Pavan

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      You want to use a PERFORM instead of using the field that already has the value you need? Okay.

      Add the "K" format option in the SAPscript variables that you pass. This stops the formatting that adds the comma.

      /: PERFORM <form-name> IN PROGRAM <Program Name>

      /: USING &RESBD-MENGE(K)&

      /: USING &RESBD-GPREIS(K)&

      /: CHANGING &V_RESULT&

      /: ENDPERFORM

  • author's profile photo Former Member
    Former Member
    Posted on Aug 14, 2009 at 08:46 AM

    Hi

    (1)

    You can directly calculate total in the program and pass it into variable before the WRITE_FORM and pass that variable into SAPscript

    (2)

    In sap script , you can use perform and call that form in program.

    in SCRIPT:

    /: PERFORM <form-name> IN PROGRAM <Program Name>

    /: USING &RESBD-MENGE&

    /: USING &RESBD-GPREIS&

    /: CHANGING &V_RESULT& " This value stores the resulting value of (&RESBD-MENGE& * RESBD-GPREIS&)

    /: ENDPERFORM

    In program

    FORM <form name> TABLES in_tab STRCUTURE itcsy

    out_tab STRCUTURE itcsy.

    READ TABLE in_tab WITH KEY 'RESBD-MENGE'.

    IF SY-SUBRC = 0.

    LV_VALUE1 = IN_TAB-VALUE.

    ENDIF.

    READ TABLE in_tab WITH KEY 'RESBD-GPREIS'.

    IF SY-SUBRC = 0.

    LV_VALUE2 = IN_TAB-VALUE.

    ENDIF.

    LV_VALUE = LV_VALUE1 * LV_VALUE2.

    READ TABLE in_tab WITH KEY 'V_RESULT'.

    IF SY-SUBRC = 0.

    OUT_TAB-VALUE = LV_VALUE1.

    ENDIF.

    ENDFORM.

    MODIFY OUT_TAB INDEX SY-TABIX.

    Try either of this one. I think it will work.

    Thanks

    Sriiiiiiiiiiii(Srikanth).

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.