Skip to Content
avatar image
Former Member

Reports

Hi friends,

Please send me some real time objects on reports to my mail

id hos.sap@gmail.com

Thanks in advance.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Mar 26, 2008 at 06:09 AM

    ----


    Hi

    i am sending some sample code.

    • DATA DECLARATION

    ----


    DATA : v_field(15),

    v_vbeln TYPE vbak-vbeln,

    v_kunnr TYPE kna1-kunnr.

    ----


    • STRUCTURE DECLARATION

    ----


    TYPES : BEGIN OF st_kna1,

    kunnr TYPE kunnr, "Customer Number

    name1 TYPE name1, "Name

    END OF st_kna1.

    TYPES : BEGIN OF st_vbak,

    kunnr TYPE kunnr,

    vbeln TYPE vbeln, "sales document

    erdat TYPE erdat, "Date on which the record was created

    ernam TYPE ernam, "Name of Person who Created the Object

    auart TYPE auart, "Sales Document Type

    audat TYPE audat, "Document Date

    END OF st_vbak.

    TYPES : BEGIN OF st_vbap,

    vbeln TYPE vbeln, "Sales Document

    posnr TYPE posnr, "Sales Document Item

    matnr TYPE matnr, "Material Number

    matwa TYPE matwa, "Material entered

    END OF st_vbap.

    ----


    • INTERNAL TABLE DECLARATIONS

    ----


    DATA : it_kna1 TYPE STANDARD TABLE OF st_kna1,

    wa_kna1 TYPE st_kna1.

    DATA : it_vbak TYPE STANDARD TABLE OF st_vbak,

    wa_vbak TYPE st_vbak.

    DATA : it_vbap TYPE STANDARD TABLE OF st_vbap,

    wa_vbap TYPE st_vbap.

    ----


    • SELECTION SCREEN

    ----


    SELECTION-SCREEN: BEGIN OF BLOCK b1.

    SELECT-OPTIONS so_kunnr FOR wa_kna1-kunnr OBLIGATORY.

    SELECTION-SCREEN END OF BLOCK b1.

    PARAMETER p_hits TYPE i.

    ----


    • START-OF-SELECTION

    ----


    START-OF-SELECTION.

    PERFORM get_data.

    SET PF-STATUS 'SOH'.

    ----


    • AT USER-COMMAND

    ----


    AT USER-COMMAND.

    CASE sy-ucomm.

    WHEN 'SOH1'.

    PERFORM first_list.

    SET PF-STATUS 'SITEM'.

    WHEN 'SITEM1'.

    PERFORM second_list.

    WHEN 'SITEM2'.

    CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

    ENDCASE.

    ----


    • AT LINE-SELECTION

    ----


    AT LINE-SELECTION.

    CASE sy-lsind.

    WHEN '1'.

    PERFORM first_list.

    WHEN '2'.

    PERFORM second_list.

    ENDCASE.

    *----


    • TOP-OF-PAGE

    ----


    TOP-OF-PAGE.

    ULINE /1(67).

    WRITE:/1 sy-vline ,

    10(15) text-002,

    sy-vline,

    30(35) text-001,

    67 sy-vline.

    ULINE /1(67).

    *----


    • TOP-OF-PAGE DURING LINE SELECTION

    *----


    TOP-OF-PAGE DURING LINE-SELECTION.

    CASE sy-lsind.

    WHEN 1.

    WRITE:/ text-000 ,

    wa_kna1-kunnr,

    30 text-001,

    wa_kna1-name1.

    ULINE AT /1(102).

    WRITE:/1 sy-vline,

    2(14) text-009 ,

    18 sy-vline,

    19(17) text-010,

    36 sy-vline,

    38(28) text-011,

    67 sy-vline,

    69(17) text-012,

    86 sy-vline,

    88(12) text-013,

    102 sy-vline.

    ULINE AT /1(102).

    WHEN 2.

    WRITE:/ text-000,

    wa_kna1-kunnr,

    40 text-001 ,

    wa_kna1-name1,

    80 text-007,

    wa_vbak-vbeln.

    ULINE AT /1(80).

    WRITE:/1 sy-vline,

    2(13) text-014,

    18 sy-vline,

    20(20) text-015,

    40 sy-vline,

    42(18) text-016,

    62 sy-vline,

    65(18) text-017,

    80 sy-vline.

    ULINE AT /1(80).

    ENDCASE.

    &----


    *& Form first_list -


    fetching data forbasic list

    &----


    FORM first_list .

    SET PF-STATUS 'SITEM'.

    GET CURSOR FIELD v_field VALUE v_kunnr.

    IF v_field = 'WA_KNA1-KUNNR'.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

    EXPORTING "first_list

    input = v_kunnr

    IMPORTING

    output = v_kunnr.

    SELECT kkunnr vvbeln verdat vernam vauart vaudat

    INTO TABLE it_vbak

    FROM vbak AS v INNER JOIN kna1 AS k ON vkunnr = kkunnr

    WHERE v~kunnr = v_kunnr.

    PERFORM disp_header.

    ELSE.

    MESSAGE text-004 TYPE 'E'.

    ENDIF.

    ENDFORM. "first_list

    &----


    *& Form second_list-------fetching data for first list

    &----


    FORM second_list .

    SET PF-STATUS space.

    GET CURSOR FIELD v_field VALUE v_vbeln .

    IF v_field = 'WA_VBAK-VBELN'.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

    EXPORTING

    input = v_vbeln

    IMPORTING "second_list

    output = v_vbeln.

    SELECT vbvbeln vpposnr vpmatnr vpmatwa

    INTO TABLE it_vbap

    FROM vbap AS vp INNER JOIN vbak AS vb ON vbvbeln = vpvbeln

    WHERE vp~vbeln = v_vbeln.

    PERFORM display_item.

    ELSE.

    MESSAGE text-008 TYPE 'E'.

    ENDIF.

    ENDFORM. "second_list

    &----


    *& Form get_data----fetching data for second list

    &----


    FORM get_data.

    CLEAR it_kna1[].

    SELECT kunnr name1

    FROM kna1

    UP TO p_hits ROWS

    INTO TABLE it_kna1 " get_data

    WHERE kunnr IN so_kunnr.

    IF sy-subrc NE 0.

    MESSAGE text-005 TYPE 'I'.

    ELSE.

    LOOP AT it_kna1 INTO wa_kna1.

    WRITE:/1 sy-vline,

    10(15) wa_kna1-kunnr,

    26 sy-vline,

    28(35) wa_kna1-name1,

    67 sy-vline.

    HIDE: wa_kna1-kunnr,

    wa_kna1-name1.

    ENDLOOP.

    ULINE /1(67).

    ENDIF.

    ENDFORM. "get_data

    "get_data

    &----


    *& Form disp_header--to display first list

    &----


    FORM disp_header .

    IF sy-subrc EQ 0.

    LOOP AT it_vbak INTO wa_vbak.

    WRITE:/1 sy-vline,

    2(14) wa_vbak-vbeln,

    18 sy-vline,

    19(17) wa_vbak-erdat,

    36 sy-vline,

    38(28) wa_vbak-ernam ,

    67 sy-vline,

    69(17) wa_vbak-auart,

    86 sy-vline,

    88(12) wa_vbak-audat,

    102 sy-vline.

    HIDE: wa_vbak-vbeln.

    ULINE AT /1(102).

    ENDLOOP.

    ELSE.

    MESSAGE text-005 TYPE 'I'.

    ENDIF.

    ENDFORM. " disp_header

    &----


    *& Form display_item -- to display second list

    &----


    FORM display_item .

    IF sy-subrc EQ 0.

    LOOP AT it_vbap INTO wa_vbap.

    WRITE:/1 sy-vline,

    2(13) wa_vbap-vbeln,

    18 sy-vline,

    20(20) wa_vbap-posnr,

    40 sy-vline,

    42(18) wa_vbap-matnr,

    62 sy-vline,

    65(18) wa_vbap-matwa,

    80 sy-vline.

    ULINE AT /1(80).

    ENDLOOP.

    ELSE.

    MESSAGE text-005 TYPE 'I'.

    ENDIF.

    ENDFORM. " display_item

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi

      requirement of that program:

      after executing give customer numbers you got one list which contains customer number and name.you select one customer number and press pushbutton(you create one for header details) then you got header details of that number and then select one sales document number then press one push button(for item details) then you got item details of that.or after selecting sales document num press anotrher push button then you went into transaction va03.

  • avatar image
    Former Member
    Mar 26, 2008 at 06:47 AM

    Hi,

    Requirement:

    Develop alv report to display the vendor and customer open

    items balance details,when both are same for particular company.

    Means: Both vendor and customer names should be equal and VAT registration sholud also be same.

    &----


    *& Report ZCSFIBALDET

    *&

    &----


    *& Report to display the Vendor and Customer open item details when

    *& both are same for particular company

    &----


    REPORT ZCSFIBALDET.

    --- Data declaration ---

    TABLES: BSIK,BSID,KNA1,LFA1,BKPF.

    TYPE-POOLS: SLIS.

    DATA: LIN TYPE I.

    -Select-options-

    SELECTION-SCREEN BEGIN OF BLOCK b1.

    SELECT-OPTIONS: bukrs1 FOR bkpf-bukrs, "#EC *

    lifnr1 FOR lfa1-lifnr, "#EC *

    kunnr1 FOR kna1-kunnr. "#EC *

    SELECTION-SCREEN END OF BLOCK b1.

    - Vendor structure for open items-

    TYPES: BEGIN OF TY_BSIK,

    BUKRS LIKE BSIK-BUKRS,

    LIFNR LIKE BSIK-LIFNR,

    PSWBT LIKE BSIK-PSWBT,

    END OF TY_BSIK.

    --- Internal table declaration for Vendor Open items ---

    DATA: IT_BSIK TYPE TABLE OF TY_BSIK INITIAL SIZE 0,

    WA_BSIK TYPE TY_BSIK.

    - Customer structure for open items-

    TYPES: BEGIN OF TY_BSID,

    BUKRS LIKE BSID-BUKRS,

    KUNNR LIKE BSID-KUNNR,

    PSWBT LIKE BSID-PSWBT,

    END OF TY_BSID.

    --- Internal table declaration for Customer Open items ---

    DATA: IT_BSID TYPE TABLE OF TY_BSID INITIAL SIZE 0,

    WA_BSID TYPE TY_BSID.

    --- Structure for Vendor and Customer open items ---

    TYPES: BEGIN OF TY_FINAL1,

    BUKRS LIKE BSID-BUKRS,

    LIFNR LIKE BSIK-LIFNR,

    KUNNR LIKE BSID-KUNNR,

    LPSWBT LIKE BSIK-PSWBT,

    KPSWBT LIKE BSID-PSWBT,

    END OF TY_FINAL1.

    --- Internal table declaration for Vendor & Customer Open items ---

    DATA: IT_FINAL1 TYPE TABLE OF TY_FINAL1 INITIAL SIZE 0,

    WA_FINAL1 TYPE TY_FINAL1.

    --- Vendor structure for VAT reg. details ---

    TYPES: BEGIN OF TY_LFA1,

    LIFNR LIKE LFA1-LIFNR,

    NAME1 LIKE LFA1-NAME1,

    STCEG LIKE LFA1-STCEG,

    END OF TY_LFA1.

    --- Internal table declaration for Vendor VAT reg. details ---

    DATA: IT_LFA1 TYPE TABLE OF TY_LFA1 INITIAL SIZE 0,

    WA_LFA1 TYPE TY_LFA1.

    --- Customer structure for VAT reg. details ---

    TYPES: BEGIN OF TY_KNA1,

    KUNNR LIKE KNA1-KUNNR,

    NAME1 LIKE KNA1-NAME1,

    STCEG LIKE KNA1-STCEG,

    END OF TY_KNA1.

    --- Internal table declaration for Customer VAT reg. details ---

    DATA: IT_KNA1 TYPE TABLE OF TY_KNA1 INITIAL SIZE 0,

    WA_KNA1 TYPE TY_KNA1.

    --- Structure for Vendor & Customer VAT reg. details ---

    TYPES: BEGIN OF TY_FINAL2,

    LLIFNR LIKE LFA1-LIFNR,

    LNAME1 LIKE LFA1-NAME1,

    LSTCEG LIKE LFA1-STCEG,

    KKUNNR LIKE KNA1-KUNNR,

    KNAME1 LIKE KNA1-NAME1,

    KSTCEG LIKE KNA1-STCEG,

    END OF TY_FINAL2.

    DATA: IT_FINAL2 TYPE TABLE OF TY_FINAL2 INITIAL SIZE 0,

    WA_FINAL2 TYPE TY_FINAL2.

    --- Main Structure for all the details ---

    TYPES: BEGIN OF TY_MAIN,

    MLLIFNR LIKE LFA1-LIFNR,

    MLNAME1 LIKE LFA1-NAME1,

    MLSTCEG LIKE LFA1-STCEG,

    MLPSWBT LIKE BSIK-PSWBT,

    MKKUNNR LIKE KNA1-KUNNR,

    MKNAME1 LIKE KNA1-NAME1,

    MKSTCEG LIKE KNA1-STCEG,

    MKPSWBT LIKE BSID-PSWBT,

    MNETBAL LIKE BSID-PSWBT,

    END OF TY_MAIN.

    DATA: IT_MAIN TYPE TABLE OF TY_MAIN INITIAL SIZE 0,

    WA_MAIN TYPE TY_MAIN.

    --- ALV Data Declaration ---

    DATA: I_FLDCAT TYPE SLIS_T_FIELDCAT_ALV,

    W_FLDCAT TYPE SLIS_FIELDCAT_ALV.

    --- AT SELECTION-SCREEN ---

    AT SELECTION-SCREEN on bukrs1.

    select single bukrs

    from bkpf

    into bkpf

    where bukrs in bukrs1.

    if sy-subrc ne 0.

    message i009(zcsmsg).

    submit (sy-repid) via selection-screen.

    endif.

    at selection-screen on lifnr1.

    select single lifnr

    from lfa1

    into lfa1

    where lifnr in lifnr1.

    if sy-subrc ne 0.

    message i009(zcsmsg).

    submit (sy-repid) via selection-screen.

    endif.

    at selection-screen on kunnr1.

    select single kunnr

    from kna1

    into kna1

    where kunnr in kunnr1.

    if sy-subrc ne 0.

    message i009(zcsmsg).

    submit (sy-repid) via selection-screen.

    endif.

    --- START-OF-SELECTION ---

    START-OF-SELECTION.

    --- Retrieving data ---

    SELECT

    BUKRS

    LIFNR

    PSWBT

    FROM BSIK INTO TABLE IT_BSIK

    WHERE BUKRS IN BUKRS1

    AND LIFNR IN LIFNR1.

    SELECT

    BUKRS

    KUNNR

    PSWBT

    FROM BSID INTO TABLE IT_BSID

    WHERE BUKRS IN BUKRS1

    AND KUNNR IN KUNNR1.

    SELECT

    LIFNR

    NAME1

    STCEG

    FROM LFA1 INTO TABLE IT_LFA1

    WHERE LIFNR IN LIFNR1.

    SELECT

    KUNNR

    NAME1

    STCEG

    FROM KNA1 INTO TABLE IT_KNA1

    WHERE KUNNR IN KUNNR1.

    LOOP AT IT_BSIK INTO WA_BSIK.

    READ TABLE IT_BSID INTO WA_BSID WITH

    KEY BUKRS = WA_BSIK-BUKRS." KUNNR = WA_BSIK-LIFNR.

    IF SY-SUBRC = 0.

    WA_FINAL1-BUKRS = WA_BSID-BUKRS.

    WA_FINAL1-LIFNR = WA_BSIK-LIFNR.

    WA_FINAL1-LPSWBT = WA_BSIK-PSWBT.

    WA_FINAL1-KUNNR = WA_BSID-KUNNR.

    WA_FINAL1-KPSWBT = WA_BSID-PSWBT.

    APPEND WA_FINAL1 TO IT_FINAL1.

    CLEAR WA_FINAL1.

    ENDIF.

    ENDLOOP.

    LOOP AT IT_LFA1 INTO WA_LFA1.

    READ TABLE IT_KNA1 INTO WA_KNA1 WITH

    KEY NAME1 = WA_LFA1-NAME1 STCEG = WA_LFA1-STCEG.

    IF SY-SUBRC = 0 AND WA_LFA1-STCEG IS NOT INITIAL.

    WA_FINAL2-LLIFNR = WA_LFA1-LIFNR.

    WA_FINAL2-LNAME1 = WA_LFA1-NAME1.

    WA_FINAL2-LSTCEG = WA_LFA1-STCEG.

    WA_FINAL2-KKUNNR = WA_KNA1-KUNNR.

    WA_FINAL2-KNAME1 = WA_KNA1-NAME1.

    WA_FINAL2-KSTCEG = WA_KNA1-STCEG.

    APPEND WA_FINAL2 TO IT_FINAL2.

    CLEAR: WA_FINAL2, WA_LFA1, WA_KNA1.

    ENDIF.

    ENDLOOP.

    LOOP AT IT_FINAL1 INTO WA_FINAL1.

    READ TABLE IT_FINAL2 INTO WA_FINAL2 WITH

    KEY LLIFNR = WA_FINAL1-LIFNR KKUNNR = WA_FINAL1-KUNNR.

    IF SY-SUBRC = 0.

    WA_MAIN-MLLIFNR = WA_FINAL2-LLIFNR.

    WA_MAIN-MLNAME1 = WA_FINAL2-LNAME1.

    WA_MAIN-MLSTCEG = WA_FINAL2-LSTCEG.

    WA_MAIN-MLPSWBT = WA_FINAL1-LPSWBT.

    WA_MAIN-MKKUNNR = WA_FINAL2-KKUNNR.

    WA_MAIN-MKNAME1 = WA_FINAL2-KNAME1.

    WA_MAIN-MKSTCEG = WA_FINAL2-KSTCEG.

    WA_MAIN-MKPSWBT = WA_FINAL1-KPSWBT.

    WA_MAIN-MNETBAL = WA_FINAL1-LPSWBT - WA_FINAL1-KPSWBT.

    APPEND WA_MAIN TO IT_MAIN.

    CLEAR: WA_MAIN, WA_FINAL1, WA_FINAL2.

    ENDIF.

    ENDLOOP.

    DESCRIBE TABLE IT_MAIN LINES LIN.

    IF LIN <> 0.

    PERFORM BLD_FLDCAT.

    PERFORM DISPLAY_ALV_REPORT.

    ELSE.

    WRITE:/ 'No records found'. "#EC NOTEXT

    ENDIF.

    --- Build Field Catalog for ALV Report ---

    FORM BLD_FLDCAT.

    W_FLDCAT-FIELDNAME = 'MLLIFNR'.

    W_FLDCAT-SELTEXT_M = 'Vendor'. "#EC NOTEXT

    W_FLDCAT-COL_POS = 0.

    W_FLDCAT-OUTPUTLEN = 10.

    APPEND W_FLDCAT TO I_FLDCAT.

    CLEAR W_FLDCAT.

    W_FLDCAT-FIELDNAME = 'MLNAME1'.

    W_FLDCAT-SELTEXT_M = 'NAME'.

    W_FLDCAT-COL_POS = 1.

    W_FLDCAT-OUTPUTLEN = 35.

    APPEND W_FLDCAT TO I_FLDCAT.

    CLEAR W_FLDCAT.

    W_FLDCAT-FIELDNAME = 'MLSTCEG'.

    W_FLDCAT-SELTEXT_M = 'VAT_REG_NO'.

    W_FLDCAT-COL_POS = 2.

    W_FLDCAT-OUTPUTLEN = 10.

    APPEND W_FLDCAT TO I_FLDCAT.

    CLEAR W_FLDCAT.

    W_FLDCAT-FIELDNAME = 'MLPSWBT'.

    W_FLDCAT-SELTEXT_M = 'AC_BALANCE'.

    W_FLDCAT-COL_POS = 3.

    W_FLDCAT-OUTPUTLEN = 15.

    APPEND W_FLDCAT TO I_FLDCAT.

    CLEAR W_FLDCAT.

    W_FLDCAT-FIELDNAME = 'MKKUNNR'.

    W_FLDCAT-SELTEXT_M = 'CUSTOMER_NO'.

    W_FLDCAT-COL_POS = 4.

    W_FLDCAT-OUTPUTLEN = 10.

    APPEND W_FLDCAT TO I_FLDCAT.

    CLEAR W_FLDCAT.

    W_FLDCAT-FIELDNAME = 'MKNAME1'.

    W_FLDCAT-SELTEXT_M = 'NAME'.

    W_FLDCAT-COL_POS = 5.

    W_FLDCAT-OUTPUTLEN = 35.

    APPEND W_FLDCAT TO I_FLDCAT.

    CLEAR W_FLDCAT.

    W_FLDCAT-FIELDNAME = 'MKSTCEG'.

    W_FLDCAT-SELTEXT_M = 'VAT_REG_NO'.

    W_FLDCAT-COL_POS = 6.

    W_FLDCAT-OUTPUTLEN = 10.

    APPEND W_FLDCAT TO I_FLDCAT.

    CLEAR W_FLDCAT.

    W_FLDCAT-FIELDNAME = 'MKPSWBT'.

    W_FLDCAT-SELTEXT_M = 'AC_BALANCE'.

    W_FLDCAT-COL_POS = 7.

    W_FLDCAT-OUTPUTLEN = 15.

    APPEND W_FLDCAT TO I_FLDCAT.

    CLEAR W_FLDCAT.

    W_FLDCAT-TABNAME = 'IT_MAIN'.

    W_FLDCAT-FIELDNAME = 'MKNETBAL'.

    W_FLDCAT-SELTEXT_M = 'Net Balance'.

    W_FLDCAT-COL_POS = 8.

    W_FLDCAT-OUTPUTLEN = 15.

    APPEND W_FLDCAT TO I_FLDCAT.

    CLEAR W_FLDCAT.

    ENDFORM. " End fieldcatalog

    --- Calling the grid function module ---

    FORM DISPLAY_ALV_REPORT.

    DATA: GD_REPID TYPE SY-REPID.

    GD_REPID = SY-REPID.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = GD_REPID

    IT_FIELDCAT = I_FLDCAT[]

    I_SAVE = 'X'

    TABLES

    T_OUTTAB = IT_MAIN

    EXCEPTIONS

    PROGRAM_ERROR = 1

    OTHERS = 2.

    ENDFORM. " End of ALV Function Module

    Reward,if it is useful.

    Thanks,

    Chandu

    Add comment
    10|10000 characters needed characters exceeded