技术开发 频道

ABAP实例:如何开发简单报表

    然后我们需要定义输出界面。把我们查询到的数据输出时要有一个输出的格式, 这样大家看起来才会方便。代码如下: 

   TOP-OF-PAGE .
      WRITE:
/'采购凭证号',22 '物料号码',
              
47 '采购订单数量',77  '收到货物数量',
              
95 '完成标志'.
         ULINE AT
/1(130).
    END
-OF-PAGE .

          START
-OF-SELECTION.

    最后就是把我们查到的数据输出了。其实我举的这个程序到这一步时穿插了一些查询,所以比较长。代码如下: 
 

     IF R1 = 'X'.
    LOOP AT ITAB.
               SELECT S
~MATNR S~MENGE P~WEMNG S~EBELN
                 INTO (MATNR, MENGE, WEMNG, EBELN)
       FROM EKPO AS S INNER JOIN EKET AS P
                              ON S
~EBELP = P~EBELP AND S~EBELN = P~EBELN
                      WHERE S
~EBELN = ITAB-EBELN.
       IF ITAB
-MENGE > ITAB-WEMNG.
               WRITE:
/2 EBELN,23 MATNR,41 MENGE,
                      
71 WEMNG,97 ''.
             ULINE AT
/1(130).
               CLEAR: EBELN,MATNR,MENGE,WEMNG.
       ENDIF.
               ENDSELECT.
    ENDLOOP.

       ELSEIF R2
= 'X'.
    LOOP AT ITAB.
                SELECT S
~MATNR S~MENGE P~WEMNG S~EBELN
                 INTO (MATNR, MENGE, WEMNG, EBELN)
         FROM EKPO AS S INNER JOIN EKET AS P
                              ON S
~EBELP = P~EBELP AND S~EBELN = P~EBELN
                      WHERE S
~EBELN = ITAB-EBELN.
       IF  ITAB
-MENGE <= ITAB-WEMNG.
                WRITE:
/2 EBELN,23 MATNR,41 MENGE,
                      
71 WEMNG,97 ''.
                ULINE AT
/1(130).
               CLEAR: EBELN,MATNR,MENGE,WEMNG.
       ENDIF.
                ENDSELECT.
    ENDLOOP.

       ELSE.
    LOOP AT ITAB.

              SELECT S
~MATNR S~MENGE P~WEMNG S~EBELN
                 INTO (MATNR, MENGE, WEMNG, EBELN)
       FROM EKPO AS S INNER JOIN EKET AS P
                              ON S
~EBELP = P~EBELP AND S~EBELN = P~EBELN
                      WHERE S
~EBELN = ITAB-EBELN.
       IF ITAB
-MENGE > ITAB-WEMNG.
               WRITE:
/2 EBELN, 23 MATNR,41 MENGE,
                      
71 WEMNG,97 ''.
             ULINE AT
/1(130).
               CLEAR: EBELN,MATNR,MENGE,WEMNG.
       ENDIF.
               ENDSELECT.
     ENDLOOP.
    ENDIF.

    LOOP AT ITAB.
    IF R3
= 'X' AND ITAB-MENGE <= ITAB-WEMNG.
              SELECT S
~MATNR S~MENGE P~WEMNG S~EBELN
                 INTO (MATNR, MENGE, WEMNG, EBELN)
       FROM EKPO AS S INNER JOIN EKET AS P
                              ON S
~EBELP = P~EBELP AND S~EBELN = P~EBELN
                      WHERE S
~EBELN = ITAB-EBELN.
          WRITE:
/2 EBELN,23 MATNR,41 MENGE,
                      
71 WEMNG,97 ''.
             ULINE AT
/1(130).
               CLEAR: EBELN,MATNR,MENGE,WEMNG.
               ENDSELECT.
           ENDIF.
    ENDLOOP.

    这时程序就结束了。其实举这个例子是想让大家知道ABAP开发报表的一个常规流程,并不是讲什么技巧之类的,希望能对初学者有点用。抛砖引玉!

0
相关文章