Skip to Content
avatar image
Former Member

SAP Scripts SUM values

Dear Friends

i have using script and taking calculated value from sub routing

FORM ZPM_GET_VALUES TABLES IN_P1 STRUCTURE ITCSY OUT_P2 STRUCTURE ITCSY.
  DATA  : V_VALUE2 TYPE MBEW-VERPR.
  DATA  : LV_MATNR TYPE MBEW-MATNR.
  DATA  : LV_WERKS TYPE MBEW-BWKEY.
  DATA  : LV_VALUE TYPE P DECIMALS 2.
  DATA  : LV_VERPR TYPE MBEW-VERPR.
  DATA  : V_VALUE  TYPE STRING.
*
  READ TABLE IN_P1 WITH KEY 'RESBD-MATNR'.
  LV_MATNR = IN_P1-VALUE.
*
  READ TABLE IN_P1 WITH KEY 'CAUFVD-VAWRK'.
  LV_WERKS = IN_P1-VALUE.
*
  READ TABLE IN_P1 WITH KEY 'RESBD-MENGE'.
  LV_VALUE = IN_P1-VALUE.
*
  SELECT  SINGLE VERPR
    INTO  LV_VERPR
    FROM  MBEW
    WHERE MATNR EQ LV_MATNR
    AND   BWKEY EQ LV_WERKS.
*
*  BREAK ITNR.
  V_VALUE2 = LV_VERPR * LV_VALUE.
  V_VALUE = V_VALUE2.
  CONDENSE V_VALUE.
*
  LOOP AT OUT_P2 WHERE NAME EQ 'V_VALUE'.
    OUT_P2-VALUE = V_VALUE.
    MODIFY OUT_P2.
  ENDLOOP.

*  BREAK ITNR.
ENDFORM.                    " ZPM_GET_VALUES

in SCRIPT

*  ------------------------------------------------------------------------ 
/E MATERIAL                                                                 
/: DEFINE &V_VALUE&=''                                                      
/: DEFINE &V_SUM&=&V_VALUE&                                                 
/: PERFORM ZPM_GET_VALUES IN PROGRAM ZIW3D_INFO                             
/: USING &RESBD-MATNR(C)&                                                   
/: USING &RESBD-MENGE(C)&                                                   
/: USING &CAUFVD-VAWRK&                                                     
/: CHANGING &V_VALUE&                                                       
/: ENDPERFORM                                                               
*   &RESBD-MATNR(C)&,, &RESBD-MATXT&,,,,&RESBD-MENGE(C)&   &RESBD-EINHEIT&  
=  ,,,,&V_VALUE&                                                            
/* SUMMING &V_VALUE& INTO &V_SUM&                                           
/: V_SUM = V_SUM + &V_VALUE&

but any values didn't take to V_SUM

please help me to solve this issue

Thanks in Advance

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Jan 07, 2010 at 07:46 AM
    /: V_SUM = V_SUM + &V_VALUE&

    You cannot write direct calculative statements in scrips.

    You might have to use Subroutines just like you have used above.and pass the sum values through OUTPAR.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 07, 2010 at 07:54 AM

    Hi

    Try using

    /: SUMMING &V_VALUE& INTO &V_SUM&
    

    Ref: http://it.toolbox.com/wiki/index.php/Sap_script#6.21.1.09Summing_and_Carrying_Forward_is_Incorrect

    Hope this solves your issue..

    Nag

    Add comment
    10|10000 characters needed characters exceeded