Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Data Not coming

Former Member
0 Likes
765

Hi all , I worte a below code for my report... I don't know what wrong , am not getting movement type descriptions for few fields in the output display... can any one help me in this ?

  METHOD  process_po_data .



*   Data declarations for temporary data storage tables

    DATA :

      lt_temp                                    TYPE ty_t_ekbe_invc,

      ls_temp                                    LIKE LINE OF lt_temp .



*   Data declarations

    DATA:

      ls_final                                   TYPE  zstth_po_docmnt_flow ,

      lv_index_inv                               TYPE  sy-tabix,

      lt_output                                  TYPE  zttth_po_docmnt_flow,

      lv_invcount                                TYPE  i.



*   Field symbols

    FIELD-SYMBOLS:

      <fs_ekko>                                  TYPE  ty_s_ekko,

      <fs_ekbe>                                  TYPE  ty_s_ekbe,

      <fs_ekbe_invc>                             TYPE  ty_s_ekbe_invc,

      <fs_t161t>                                 TYPE  ty_s_t161t,

      <fs_t156t>                                 TYPE  ty_s_t156t.



*   Loop ekko table to fetch all Po's which doesn't have History data

    LOOP AT it_ekko ASSIGNING <fs_ekko>.



*     Read table ekko

      READ TABLE it_ekbe

        ASSIGNING <fs_ekbe>

        WITH KEY ebeln = <fs_ekko>-ebeln .



      IF sy-subrc <> 0.                                       "Po's which has no History data



*     Po number

        ls_final-zebeln      = <fs_ekko>-ebeln.

*     Site

        ls_final-zwerks      = <fs_ekko>-werks.

*     Po date

        ls_final-zbedat      = <fs_ekko>-bedat.

*     Document type

        ls_final-zbsart      = <fs_ekko>-bsart.



        AT NEW ebeln.

*     Po count

          ls_final-zpocount    = zcl_constants=>constant_1 .

        ENDAT.



*     Read table t161t

        READ TABLE it_t161t

          ASSIGNING <fs_t161t>

          WITH  KEY bsart   = <fs_ekko>-bsart

          BINARY SEARCH.



        IF sy-subrc EQ 0.

*       Document type description

          ls_final-zbatxt    = <fs_t161t>-batxt.

        ENDIF.



*        Append workarea to internal table

        APPEND  ls_final TO lt_output .

        CLEAR ls_final .

      ENDIF .

    ENDLOOP.



*   Loop Ekbe table to process final data

    LOOP AT it_ekbe ASSIGNING <fs_ekbe>.



*     Movement type

        ls_final-zbwart      = <fs_ekbe>-bwart.

*     Article documents

        ls_final-zbelnr      = <fs_ekbe>-belnr.

*     Gr date

        ls_final-zbudat      = <fs_ekbe>-budat.



      AT NEW belnr.

*     Gr count

        ls_final-zgr_count   = zcl_constants=>constant_1.

      ENDAT.



*     Read table ekko

      READ TABLE it_ekko

        ASSIGNING <fs_ekko>

        WITH KEY ebeln = <fs_ekbe>-ebeln.

      IF sy-subrc EQ 0.

        AT NEW ebeln.

*     Po number

        ls_final-zebeln      = <fs_ekko>-ebeln.

*     Site

        ls_final-zwerks      = <fs_ekko>-werks.

*     Po date

        ls_final-zbedat      = <fs_ekko>-bedat.

*     Document type

        ls_final-zbsart      = <fs_ekko>-bsart.



*     Po count

        ls_final-zpocount    = zcl_constants=>constant_1 .



*     Read table t161t

      READ TABLE it_t161t

        ASSIGNING <fs_t161t>

        WITH  KEY bsart   = <fs_ekko>-bsart

        BINARY SEARCH.



          IF sy-subrc EQ 0.



*     Document type description

            ls_final-zbatxt    = <fs_t161t>-batxt.



          ENDIF.

        ENDAT.

      ENDIF .





        AT NEW ebeln .

        REFRESH  lt_temp .

        lv_invcount = 1 .

        lv_index_inv = 1.

        ENDAT .



      IF lv_invcount = 1 .



*     Collect all invoice data into a temp table for a respective Po number

      LOOP AT it_ekbe_invc ASSIGNING <fs_ekbe_invc> WHERE ebeln = <fs_ekbe>-ebeln .

*     Po number

        ls_temp-ebeln      =  <fs_ekbe_invc>-ebeln.

*     Invoice number

        ls_temp-belnr      =  <fs_ekbe_invc>-belnr .

*     Invoice date

        ls_temp-budat      =  <fs_ekbe_invc>-budat .



*     Append workarea to internal table

        APPEND ls_temp TO lt_temp .

        lv_invcount = 2 .



      ENDLOOP .

    ENDIF .



*     Read Temp table to populate Invoice data

      READ TABLE lt_temp

        INTO ls_temp

        INDEX lv_index_inv .



      IF sy-subrc EQ 0.

*     Invoice number

        ls_final-zlfbnr    =  ls_temp-belnr .

*     Invoice date

        ls_final-zinvcdat  =  ls_temp-budat .

*     Invoice count

        ls_final-zinvcount = zcl_constants=>constant_1.



*       Increment the index value to read from next line

        lv_index_inv = lv_index_inv + 1 .

      ENDIF.



*     Read table t156t to fetch Movement type descriptions

      READ TABLE it_t156t

        ASSIGNING <fs_t156t>

        WITH KEY bwart = <fs_ekbe>-bwart

        BINARY SEARCH .



      IF sy-subrc EQ 0 .

*     Movement type description

        ls_final-zbwartdescpn  = <fs_t156t>-btext .

      ENDIF.



*     Append workarea to internal table

      APPEND ls_final TO  lt_output.

      CLEAR: ls_final-zgr_count,

             ls_final-zbwart,

             ls_final-zbwartdescpn,

             ls_final-zbelnr,

             ls_final-zbudat,

             ls_final-zinvcount,

             ls_final-zinvcdat,

             ls_final-zlfbnr,

             ls_final-zpocount,

             ls_final-zwerks,

             ls_final-zbatxt,

             ls_final-zbsart,

             ls_final-zebeln,

             ls_temp.



      AT END OF ebeln.



*       Fill the remaining Invoices with respect to a Po number

        LOOP AT lt_temp INTO ls_temp FROM lv_index_inv.

*       Invoice number

          ls_final-zlfbnr    =  ls_temp-belnr .

*       Invoice date

          ls_final-zinvcdat  =  ls_temp-budat .

*       Invoice count

          ls_final-zinvcount = zcl_constants=>constant_1.



*        Append workarea to internal table

          APPEND  ls_final TO lt_output .

        ENDLOOP.

        CLEAR : ls_final.

        REFRESH lt_temp .

      ENDAT .

    ENDLOOP.



*   Unassign the field symbols

    UNASSIGN: <fs_ekko>,

              <fs_ekbe>,

              <fs_t161t>.

    CLEAR ls_final.



*   Display alv if print preview is not selected

    IF p_print IS INITIAL.

      CALL METHOD me->display_data

        CHANGING

          ct_output = lt_output.

    ELSE.

*   If print preview is selected

      me->print_form(

        EXPORTING

          it_output = lt_output ).

    ENDIF.

  ENDMETHOD .                    "process_po_data

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
659

Hi Sunita,

                 Can you tell me in which statement you are not getin data? please check in debug mode...properly .

Regards,

Shiv

5 REPLIES 5
Read only

Former Member
0 Likes
660

Hi Sunita,

                 Can you tell me in which statement you are not getin data? please check in debug mode...properly .

Regards,

Shiv

Read only

0 Likes
659

Hi shiva  ,

*     Read table t156t to fetch Movement type descriptions

      READ TABLE it_t156t

        ASSIGNING <fs_t156t>

        WITH KEY bwart = <fs_ekbe>-bwart

        BINARY SEARCH .

      IF sy-subrc EQ 0 .

*     Movement type description

        ls_final-zbwartdescpn  = <fs_t156t>-btext .

      ENDIF.

here am not getting for few records , not getting why. I hav checked entire code

Read only

0 Likes
659

Hi , even i checked everything u wrote look correct.  may be its wrong with test data or re check weather u did a sorting with the key u read in read statement in asceneding order or not . that's all can be done..

Read only

0 Likes
659

thank you , I missed sorting on that particular internal table . it works fine now.. thankyou soo much

Read only

Former Member
0 Likes
659

Pl. sort your internal table by field before using binary search.

Regards

Vivek