美文网首页SAP收藏文章
根据月份累加金额

根据月份累加金额

作者: Mmm_余安 | 来源:发表于2017-06-09 11:17 被阅读73次
    • 间接法
      1.根据输入日期连接为所需要格式
      SHIFT l_rpmax LEFT DELETING LEADING ''.
      SHIFT l_rpmax LEFT DELETING LEADING '0'.
      IF l_rpmax+1(1) = ''.
        CONCATENATE '0' l_rpmax INTO l_rpmax.
      ENDIF.
      CONCATENATE 'W_FAGL-HSL' l_rpmax INTO p_fhsl.```
    
    2.按科目取数、SELECT累加单次金额
    ```  DATA lt_fhsl(12) TYPE c.
      LOOP AT it_zfir002 WHERE rownb = p_rownb
     AND raccf NE ''.
        CLEAR: l_curr, l_hslvt.
      select
        saknr
      into table gt_saknr
      from skb1
      where ALTKT BETWEEN  it_zfir002-raccf and it_zfir002-racct.```
    
    
      ``` loop at gt_saknr into gs_saknr.
     SELECT SUM( hslvt ) SUM( hsl01 ) SUM( hsl02 ) SUM( hsl03 )
     SUM( hsl04 ) SUM( hsl05 ) SUM( hsl06 ) SUM( hsl07 )
     SUM( hsl08 ) SUM( hsl09 ) SUM( hsl10 ) SUM( hsl11 )
    SUM( hsl12 )
    "INTO CORRESPONDING FIELDS OF w_fagl
    INTO (w_fagl-hslvt,w_fagl-hsl01,w_fagl-hsl02,w_fagl-hsl03,
     w_fagl-hsl04,w_fagl-hsl05,w_fagl-hsl06,w_fagl-hsl07,w_fagl-hsl08,
    w_fagl-hsl09,w_fagl-hsl10,w_fagl-hsl11,w_fagl-hsl12)
    FROM faglflext
    WHERE rbukrs = it_zfir002-bukrs
    AND ryear = p_ryear
     AND racct  =  gs_saknr-saknr
     AND rfarea = it_zfir002-rfarea
    AND rldnr IN s_rldnr.```
    
    3.将期间金额累加
    *&-----------每循环一次lt_fhsl+1,累加
    ``` lt_fhsl = l_fhsl.
        WHILE lt_fhsl LE l_lhsl.
          WRITE (lt_fhsl) TO l_hslvt.
          lt_fhsl+10(2) = lt_fhsl+10(2) + 1.
          IF lt_fhsl+11(1) = ''.
            lt_fhsl+11(1) = lt_fhsl+10(1).
            lt_fhsl+10(1) = '0'.
          ENDIF.```
    
       ```   PERFORM frm_char_to_number USING l_hslvt
                            CHANGING l_curr.
          IF it_zfir002-symbl <> 'X'.
            "( it_zfir002-accty = '+' AND it_zfir002-symbl = '' ) OR
             "( it_zfir002-accty = '-' AND it_zfir002-symbl = 'X' ).
            IF p_rownb+2(1) = 'A'.
              p_qimo = p_qimo + l_curr.
            ELSE.
              p_qimo = p_qimo - l_curr.
            ENDIF.
          ELSE.
            IF p_rownb+2(1) = 'A'.
              p_qimo = p_qimo + l_curr.
            ELSE.
              p_qimo = p_qimo - l_curr.
            ENDIF.
          ENDIF.
        ENDWHILE.```
    
    * 直接法
    ``` DATA:l_vary  LIKE faglflext-hsl01, "FAGLFLEXT表字段变量
    l_rpmax LIKE faglflext-rpmax. "最大执行次数
        l_rpmax = p_monat - 1. "输入的日期-1
        g_sum01 = 0.
        g_sum02 = 0.```
    
    
       ``` LOOP AT t_faglflext INTO w_faglflext.
          g_sum01 = g_sum01 + w_faglflext-hslvt.
          g_sum02 = g_sum02 + w_faglflext-hslvt.
          DO l_rpmax TIMES VARYING l_vary FROM w_faglflext-hsl01 NEXT w_faglflext-hsl02. "将总帐的第一个期间到当前期间累加到l_vary 变量表.
            g_sum01 = g_sum01 + l_vary.
          ENDDO.
        ENDLOOP.```
    ######多用变量会省下很多时间

    相关文章

      网友评论

        本文标题:根据月份累加金额

        本文链接:https://www.haomeiwen.com/subject/rqwxqxtx.html