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

Regarding ABAP report

Hi Experts,

I have to create a report in the following format:

Report

...................................................................................

AA |Date | X |Y | Z | XX | YY

.......................................................................................

11:30|05/10/08| 989 |4567 | B | A | A

.....................................................................................

Maria Smith 123 Main St. Apt.

....................................................................................

990-876-0987 Neighborhood City

.........................................................................................

Some message for header

.........................................................................................

.....................................................................................

Item ABC GHI OPQ RST

DEF IJK/LMN 1 KG

.....................................................................................

0010 09876 Books 908 WHP/ 1000

.........................................................................................

0020 87878 Ice Maker 1 KG

876 WHP/ M909

..................................................................................... Some message for item

.....................................................................................

Here first row is header and second row is corressponding values and the third & fourth line are customer address informations and fifth row is the messafe for header. this is just one record.

After this in the second part is the item information for the value X in the header. there are 2 items 0010 and 0020 and there corresponding details

Also when the user click on the value 989, corresponding transacion should open. say MM03

please give me some example reports with these two cases .

ie classical and interactive features.

Thanks a lot.

Useful answers will be highly rewarded.

Reagrs

Krishan

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Jul 31, 2008 at 05:01 AM

    KK,

    REPORT zm_vendor_payments LINE-SIZE 255 LINE-COUNT 65.
    ************************************************************************
    ** Vendor payment details
    **-----------------------
    ** Amit gujargoud - Inverted Sphere Inc. 2003/03/26
    *-----------------------------------------------------------------------
    ** modification history
    ** by   date      description
    *-----------------------------------------------------------------------
    ** DO   20031107  include reversal transaction as well. improve
    *                 report legibility.
    *       20031110  Add drilldown capability
    *----------------------------------------------------------------------
    * Agujargoud 2007/04.29 - New Client Upgrade.
    *---------------------------------------------------------------------
    ************************************************************************
    TABLES: bsik, bsak, bsis, bsas, bseg, ekpo, lfa1.
    
    *-----------------------------------------------------------------------
    SELECTION-SCREEN: BEGIN OF BLOCK blk1 WITH FRAME TITLE text-010,
                      SKIP.
    SELECT-OPTIONS: s_lifnr FOR bsik-lifnr,
                    s_bukrs FOR bsik-bukrs,
                    s_budat FOR bsik-budat.
    PARAMETERS:     p_grdat LIKE bsik-augdt.
    SELECTION-SCREEN: SKIP,
                      END OF BLOCK blk1.
    
    *-----------------------------------------------------------------------
    DATA: BEGIN OF i_docs OCCURS 0,
            lifnr LIKE bseg-lifnr,
            hkont LIKE bseg-hkont,
            dmbtr LIKE bsis-dmbtr,
            kostl LIKE bseg-kostl,
            sgtxt LIKE bseg-sgtxt,
            bukrs LIKE bseg-bukrs,
            belnr LIKE bseg-belnr,
            buzei LIKE bseg-buzei,
            blart LIKE bkpf-blart,
            shkzg LIKE bseg-shkzg,
            budat LIKE bkpf-budat,
            augbl LIKE bseg-augbl,
            gjahr LIKE bseg-gjahr,
          END OF i_docs.
    
    DATA: i_revs LIKE i_docs OCCURS 100 WITH HEADER LINE,
          lifnr LIKE i_docs-lifnr,
            bukrs LIKE i_docs-bukrs,
            belnr LIKE i_docs-belnr,
            blart LIKE i_docs-blart,
            hkont LIKE i_docs-hkont,
            dmbtr LIKE i_docs-dmbtr,
            kostl LIKE i_docs-kostl,
            sgtxt LIKE i_docs-sgtxt,
            budat LIKE i_docs-budat,
            total LIKE i_docs-dmbtr,
            gjahr LIKE i_docs-gjahr,
            w_ebeln LIKE ekpo-ebeln,
            w_ebelp LIKE ekpo-ebelp,
            w_zuonr LIKE bseg-zuonr,
            toggle TYPE i VALUE 1.
    
    DATA: v_grir_acct LIKE bsis-hkont,
          v_coa LIKE t001-ktopl.
    *-----------------------------------------------------------------------
    START-OF-SELECTION.
    
      CASE sy-mandt.
        WHEN '500'.
          v_coa = 'MACK'.
        WHEN '600'.
          v_coa = 'COA1'.
      ENDCASE.
    
      SELECT konts FROM t030 INTO v_grir_acct
             WHERE ktopl = v_coa
               AND ktosl = 'WRX'.
      ENDSELECT.
    
      SELECT hkont dmbtr kostl sgtxt bukrs belnr
             buzei blart shkzg budat augbl gjahr
              FROM bsis
              INTO CORRESPONDING FIELDS OF TABLE i_docs
    *                     WHERE hkont = '211200' "goods received w/o invoice
                          WHERE hkont = v_grir_acct
                          AND   bukrs IN s_bukrs
                          AND   budat IN s_budat.
    *                      AND   blart = 'WE'.
    
    
      SELECT hkont dmbtr kostl sgtxt bukrs belnr
             buzei blart shkzg budat augbl gjahr
              FROM bsas
              APPENDING CORRESPONDING FIELDS OF TABLE i_docs
    *                     WHERE hkont = '211200' "goods received w/o invoice
                          WHERE hkont = v_grir_acct
                          AND   bukrs IN s_bukrs
                          AND   budat IN s_budat
    *                      AND   blart = 'WE'
                          AND   augdt GE p_grdat.
    
      LOOP AT i_docs.
    
        SELECT SINGLE lifnr ebeln ebelp FROM bseg
               INTO (i_docs-lifnr, w_ebeln, w_ebelp)
                                  WHERE bukrs = i_docs-bukrs
                                  AND   belnr = i_docs-belnr
                                  AND   buzei = i_docs-buzei.
        IF i_docs-lifnr IN s_lifnr.
          IF NOT w_ebeln IS INITIAL AND i_docs-sgtxt IS INITIAL.
            SELECT SINGLE txz01 FROM ekpo INTO i_docs-sgtxt
                                    WHERE ebeln = w_ebeln
                                    AND   ebelp = w_ebelp.
          ENDIF.
          MODIFY i_docs.
        ELSE.
          DELETE i_docs.
        ENDIF.
      ENDLOOP.
    
      SELECT lifnr hkont dmbtr kostl sgtxt bukrs belnr
             buzei blart shkzg budat augbl gjahr
             FROM bsik
             APPENDING TABLE i_docs
                         WHERE lifnr IN s_lifnr
                         AND   bukrs IN s_bukrs
                         AND   budat IN s_budat
    *                     AND   blart IN ('KR', 'RE').
                         AND   blart IN ('KR', 'RE', 'KN', 'RN').
    
    *see if there are reversal documents
      SELECT lifnr hkont dmbtr kostl sgtxt bukrs belnr
             buzei blart shkzg budat augbl gjahr
             FROM bsik
             APPENDING TABLE i_revs
                         WHERE lifnr IN s_lifnr
                         AND   bukrs IN s_bukrs
                         AND   blart IN ('KA').
    
      SELECT lifnr hkont dmbtr kostl sgtxt bukrs belnr
             buzei blart shkzg budat augbl gjahr
             FROM bsak
             APPENDING TABLE i_docs
                         WHERE lifnr IN s_lifnr
                         AND   bukrs IN s_bukrs
                         AND   budat IN s_budat
    *                     AND   blart IN ('KR', 'RE').
                         AND   blart IN ('KR', 'RE', 'KN', 'RN').
    * check for reversal
      SELECT lifnr hkont dmbtr kostl sgtxt bukrs belnr
             buzei blart shkzg budat augbl gjahr
             FROM bsak
             APPENDING TABLE i_revs
                         WHERE lifnr IN s_lifnr
                         AND   bukrs IN s_bukrs
                         AND   blart IN ('KA').
    
    
      SORT: i_docs BY lifnr bukrs budat hkont,
            i_revs BY lifnr bukrs augbl.
    
      LOOP AT i_docs.
    
        toggle = toggle * -1.
    
        AT NEW lifnr.
          SELECT SINGLE name1 FROM lfa1 INTO lfa1-name1
                              WHERE lifnr = i_docs-lifnr.
          CLEAR total.
        ENDAT.
    
        IF i_docs-blart = 'KR' OR i_docs-blart EQ 'KN'.
          SELECT SINGLE hkont kostl gjahr FROM bseg
               INTO (i_docs-hkont, i_docs-kostl, i_docs-gjahr)
                                  WHERE bukrs = i_docs-bukrs
                                  AND   belnr = i_docs-belnr
                                  AND   kostl <> ' '.
    
        ELSEIF i_docs-blart = 'RE' OR i_docs-blart = 'RN'.
          SELECT SINGLE hkont kostl gjahr ebeln ebelp FROM bseg
               INTO (i_docs-hkont, i_docs-kostl, i_docs-gjahr,
                     w_ebeln, w_ebelp)
                                  WHERE bukrs = i_docs-bukrs
                                  AND   belnr = i_docs-belnr
                                  AND   ebeln <> ' '.
          IF NOT w_ebeln IS INITIAL
           AND i_docs-sgtxt IS INITIAL.
            SELECT SINGLE txz01 FROM ekpo INTO i_docs-sgtxt
                                    WHERE ebeln = w_ebeln
                                    AND   ebelp = w_ebelp.
          ENDIF.
        ENDIF.
    
        CASE i_docs-shkzg.
          WHEN 'S'.
            i_docs-dmbtr = i_docs-dmbtr * -1.
        ENDCASE.
    
        lifnr = i_docs-lifnr.
        bukrs = i_docs-bukrs.
        belnr = i_docs-belnr.
        blart = i_docs-blart.
        hkont = i_docs-hkont.
        dmbtr = i_docs-dmbtr.
        kostl = i_docs-kostl.
        sgtxt = i_docs-sgtxt.
        budat = i_docs-budat.
        gjahr = i_docs-gjahr.
    
    
        PERFORM print_document USING lifnr lfa1-name1 bukrs belnr blart
                                     hkont dmbtr kostl sgtxt budat gjahr.
    
        total = total + dmbtr.
    
        IF i_docs-blart = 'KR' OR i_docs-blart EQ 'KN'.
          READ TABLE i_revs WITH KEY lifnr = i_docs-lifnr
                                     bukrs = i_docs-bukrs
                                     belnr = i_docs-augbl
                                     blart = 'KA'.
          IF sy-subrc EQ 0.
            dmbtr = i_revs-dmbtr * -1.
            lifnr = i_revs-lifnr.
            bukrs = i_revs-bukrs.
            belnr = i_revs-belnr.
            blart = i_revs-blart.
            hkont = i_revs-hkont.
            kostl = i_revs-kostl.
            sgtxt = space.
            budat = i_revs-budat.
            gjahr = i_revs-gjahr.
    
            PERFORM print_document USING lifnr lfa1-name1 bukrs belnr blart
                                        hkont dmbtr kostl sgtxt budat gjahr.
    
    
            total = total + dmbtr.
    
          ENDIF.
        ENDIF.
    
    
        AT END OF lifnr.
          SKIP.
          FORMAT COLOR COL_TOTAL INTENSIFIED.
          WRITE:/ text-011, i_docs-lifnr,
               (14) total UNDER dmbtr.
          SKIP.
          FORMAT RESET.
        ENDAT.
    
      ENDLOOP.
    
    *-----------------------------------------------------------------------
    AT LINE-SELECTION.
    
      CHECK belnr NE space.
    
      SET PARAMETER ID: 'BLN' FIELD belnr,"this is your second answer
                        'BUK' FIELD bukrs,
                        'GJR' FIELD gjahr.
    
      CALL TRANSACTION 'FB03'."this is the way to call transaction for perticuler doc
    
    
    *---------------------------------------------------------------------*
    *       FORM print_document                                           *
    *---------------------------------------------------------------------*
    *       ........                                                      *
    *---------------------------------------------------------------------*
    FORM print_document    USING lifnr name1 bukrs belnr blart hkont dmbtr
                           kostl sgtxt budat gjahr.
    
    
      IF toggle GT 0.
        FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
      ELSE.
        FORMAT COLOR COL_NORMAL INTENSIFIED ON.
      ENDIF.
    
      WRITE:/ lifnr,
              name1,
              bukrs,
              belnr COLOR COL_KEY HOTSPOT,
              blart,
          (6) hkont,
         (14) dmbtr,
          (7) kostl,
              sgtxt,
              budat.
    
      HIDE: belnr, lifnr, bukrs, gjahr.
    
    ENDFORM.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 31, 2008 at 05:03 AM

    Hi,

    Check the below code sample-

    
    
    TABLES:
      kna1.                                " General Data In Customer.
    *"-------------------------------------------------------------------"*
    *Work variable Declaration.
    *"-------------------------------------------------------------------"*
    DATA:
      w_cursor TYPE string.                " Cursor Position Variable.
    *"-------------------------------------------------------------------"*
    *Parameter Declaration To Take Input.
    *"-------------------------------------------------------------------"*
    SELECT-OPTIONS:
      s_kunnr FOR kna1-kunnr OBLIGATORY.   " Input Customer No.
    *"-------------------------------------------------------------------"*
    *Field String Declaration To Hold Customer Records.
    *"-------------------------------------------------------------------"*
    DATA:
      BEGIN OF fs_sales,
        kunnr TYPE kna1-kunnr,             " Customer No.
        bname TYPE kna1-name1,             " Customer Name.
        aufnr TYPE vbak-aufnr,             " Order No.
      END OF fs_sales.                     " BEGIN OF fs_sales.
    *"-------------------------------------------------------------------"*
    *Field String Declaration To Hold Sales Information.
    *"-------------------------------------------------------------------"*
    DATA:
      BEGIN OF fs_order,
        posnr    TYPE vbap-posnr,          " Sales Item No.
        matnr    TYPE vbap-matnr,          " Material No.
        quantity TYPE vbap-zmeng,          " Quantity.
        price    TYPE vbap-netpr,          " Price.
      END OF fs_order.                     " BEGIN OF fs_order.
    *"-------------------------------------------------------------------"*
    *Internal Table Declaration To Hold Customer Information.
    *"-------------------------------------------------------------------"*
    DATA:
      t_sales LIKE STANDARD TABLE          " Sales Detail Internal Table.
           OF fs_sales.
    *"-------------------------------------------------------------------"*
    *Internal Table Declaration To Hold Sales Information.
    *"-------------------------------------------------------------------"*
    DATA:
      t_order LIKE STANDARD TABLE          " Order Detail Internal Table.
           OF fs_order.
    *"-------------------------------------------------------------------"*
    *At LINE-SELECTION.
    *"-------------------------------------------------------------------"*
    AT LINE-SELECTION.
      IF sy-lsind LE 1 AND sy-lilli GE 4.
    ****Calling Subroutine*****
        PERFORM get_order_details.
        PERFORM display_order_details.
      ELSE.
        MESSAGE i003(zyh1151).
      ENDIF.                               " IF sy-lsind LE 1.
    *"-------------------------------------------------------------------"*
    *AT USER-COMMAND.
    *"-------------------------------------------------------------------"*
    AT USER-COMMAND.
    **Assigning Memory ID******
    
    
    
      CASE sy-ucomm.
        WHEN 'CUST'.
          IF sy-lsind LE 1 AND sy-lilli GE 4.
            IF sy-cucol BETWEEN 2 AND 14.
              GET CURSOR FIELD w_cursor.
              IF w_cursor EQ 'FS_SALES-KUNNR'.
                READ LINE sy-lilli FIELD VALUE
                fs_sales-kunnr.
                IF fs_sales-kunnr IS NOT INITIAL.
                  SET PARAMETER ID 'KUN' FIELD fs_sales-kunnr.
    ***********Calling Subroutine****
                  PERFORM customer_info.
                ENDIF.
              ENDIF.
            ELSE.
              MESSAGE i003(zyh1151).
    
            ENDIF.                         " IF sy-cucol BETWEEN 2 AND....
          ELSE.
            MESSAGE i003(zyh1151).
          ENDIF.                           " IF sy-lsind LE 1 AND sy-lilli.
        WHEN 'ORDER'.
          IF sy-lsind LE 1 AND sy-lilli GE 4.
            IF sy-cucol BETWEEN 30 AND 40.
              GET CURSOR FIELD w_cursor.
              IF w_cursor EQ 'FS_SALES-AUFNR'.
                READ LINE sy-lilli FIELD VALUE
                fs_sales-aufnr.
                IF fs_sales-aufnr IS NOT INITIAL.
                  SET PARAMETER ID 'AUN' FIELD fs_sales-aufnr.
    
    ***********Calling Subroutine****
                  PERFORM order_info.
                ENDIF.
              ENDIF.
            ELSE.
              MESSAGE i003(zyh1151).
    
            ENDIF.                         " IF sy-cucol BETWEEN 30 AND 40.
          ELSE.
            MESSAGE i003(zyh1151).
    
          ENDIF.                           " IF sy-lsind LE 1 AND sy-lilli.
      ENDCASE.                             " CASE sy-ucomm.
    *"-------------------------------------------------------------------"*
    *STAR-OF-SELECTION.
    *"-------------------------------------------------------------------"*
    START-OF-SELECTION.
    **Calling Subroutine****
      PERFORM get_data.
    *"-------------------------------------------------------------------"*
    *END-OF-SELECTION.
    *"-------------------------------------------------------------------"*
    END-OF-SELECTION.
    **Calling PF-STATUS*****
      SET PF-STATUS 'CUSTOM'.
    **Calling Subroutine****
      PERFORM display_data.
    *&---------------------------------------------------------------------*
    *&      Form  get_data
    *&---------------------------------------------------------------------*
    *       Subroutine To Fetch Data from KNA1 And VBAK Table.
    *----------------------------------------------------------------------*
    *       No Interface Parameter Passed.
    *----------------------------------------------------------------------*
    FORM get_data .
      SELECT a~kunnr                       " Customer No.
             a~name1                       " Customer Name.
             b~aufnr                       " Order Number.
    
        FROM kna1 AS a
        JOIN vbak AS b
          ON a~kunnr = b~kunnr
        INTO TABLE t_sales
       WHERE a~kunnr IN s_kunnr.
      IF sy-subrc <> 0.
        MESSAGE i008(zyh1151).
      ENDIF.
    ENDFORM.                               " Form get_data
    *&---------------------------------------------------------------------*
    *&      Form  display_data
    *&---------------------------------------------------------------------*
    *       Subroutine To Display Customer Information.
    *----------------------------------------------------------------------*
    *       No Interface Parameter Passed.
    *----------------------------------------------------------------------*
    FORM display_data .
      LOOP AT t_sales INTO fs_sales.
        AT FIRST.
          WRITE:
            /  'Customer No.'(001),
            15 'Customer Name'(002),
            30 'Order No'(003).
        ENDAT.                             " AT FIRST.
        WRITE:
          / fs_sales-kunnr,
          15 fs_sales-bname,
          30 fs_sales-aufnr.
        HIDE:
          fs_sales-aufnr.
      ENDLOOP.                             " LOOP AT t_sales INTO...
      CLEAR fs_sales.
    ENDFORM.                               " Form display_data
    *&---------------------------------------------------------------------*
    *&      Form  customer_info
    *&---------------------------------------------------------------------*
    *       Subroutine For Calling New Transaction Of Display Customer.
    *----------------------------------------------------------------------*
    *       No Interface Parameter Passed.
    *----------------------------------------------------------------------*
    FORM customer_info .
      CALL TRANSACTION 'XD03'.
    ENDFORM.                               " Form customer_info
    *&---------------------------------------------------------------------*
    *&      Form  order_info
    *&---------------------------------------------------------------------*
    *       Subroutine For Calling New Transaction Of Sales Order.
    *----------------------------------------------------------------------*
    *       No Interface Parameter Passed.
    *----------------------------------------------------------------------*
    FORM order_info .
      CALL TRANSACTION 'VA03'.
    ENDFORM.                               " Form order_info
    *&---------------------------------------------------------------------*
    *&      Form  get_order_details
    *&---------------------------------------------------------------------*
    *       Subroutine For Fetching Data From VBAP Table.
    *----------------------------------------------------------------------*
    *       No Interface Parameter Passed.
    *----------------------------------------------------------------------*
    FORM get_order_details .
      SELECT posnr                         " Item Number.
             matnr                         " Material Number.
             zmeng                         " Quantity.
             netpr                         " Price.
        FROM vbap
        INTO TABLE t_order
       WHERE aufnr = fs_sales-aufnr.
    ENDFORM.                               " Form get_order_details
    *&---------------------------------------------------------------------*
    *&      Form  display_order_details
    *&---------------------------------------------------------------------*
    *       Subroutine For Displaying Output Of Order Details.
    *----------------------------------------------------------------------*
    *       No Interface Parameter Passed.
    *----------------------------------------------------------------------*
    FORM display_order_details .
      LOOP AT t_order INTO fs_order.
        AT FIRST.
          WRITE:
              /  'Item No'(004),
              15 'Material No.'(005),
              38 'Quantity'(006),
              53 'Price'(007).
        ENDAT.
        WRITE:
          /  fs_order-posnr,
          15 fs_order-matnr,
          28 fs_order-quantity,
          46 fs_order-price.
      ENDLOOP.                             " LOOP AT t_order INTO fs_order.
    ENDFORM.                               " Form display_order_details.
    

    Regards,

    Sujit

    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.