Application Development 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: 

abap not getting output. no syntax error but no data in output

former_member622718
Participant
0 Kudos
REPORT zmanoj3.
TABLES : vbap , makt.

TYPES : BEGIN OF ty,
          vbeln TYPE vbeln,
          posnr TYPE posnr,
          matnr TYPE matnr,
          makt  TYPE makt,
        END OF ty.
DATA : it TYPE TABLE OF ty,
       wa TYPE ty.
DATA: num TYPE vbap-vbeln.

SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS num1 FOR num.
SELECTION-SCREEN END OF BLOCK b.
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
      wa_fieldcat TYPE slis_fieldcat_alv,
      layout      TYPE slis_layout_alv.


DATA repid TYPE sy-repid.

START-OF-SELECTION.

  SELECT vbeln,
         posnr,
         matnr FROM vbap INTO TABLE @DATA(gt_vbap)
         WHERE vbeln IN @num1.

  IF sy-subrc EQ 0.

    SELECT matnr,
           maktx FROM makt INTO TABLE @DATA(gt_makt) FOR ALL ENTRIES IN @gt_vbap
           WHERE matnr EQ @gt_vbap-matnr.
    LOOP AT gt_vbap INTO DATA(wa_vbap).
      READ TABLE gt_makt INTO DATA(wa_makt) WITH KEY matnr = wa_vbap-matnr.
    ENDLOOP.

  ENDIF.


  wa_fieldcat-fieldname = 'vbeln'.
  wa_fieldcat-ref_tabname = 'vbap'.
  wa_fieldcat-seltext_m = 'Accounting Document Number'.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.

  wa_fieldcat-fieldname = 'posnr'.
  wa_fieldcat-ref_tabname = 'vbap'.
  wa_fieldcat-seltext_m = 'Document Number'.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.

  wa_fieldcat-fieldname = 'matnr'.
  wa_fieldcat-ref_tabname = 'vbap'.
  wa_fieldcat-seltext_m = 'Number'.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.

  wa_fieldcat-fieldname = 'maktx'.
  wa_fieldcat-ref_tabname = 'makt'.
  wa_fieldcat-seltext_m = 'Accoun Number'.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program = repid
      i_grid_title       = 'ACCOUNTING DOCUMENT DETAILS'
      it_fieldcat        = it_fieldcat
    TABLES
      t_outtab           = it.
1 ACCEPTED SOLUTION

stekoester
Explorer

Hi Manoj,

you have to merge the data of vbap and makt into your output table "it" as philip.davy2, mateuszadamus and sandra.rossi already told.

I know that you started new in ABAP, but you have to start learning the basics in ABAP first. I gave this advise already in our telegram group as you know.

REPORT zmanoj3.
TABLES : vbap , makt.
TYPES : BEGIN OF ty,
          vbeln TYPE vbeln,
          posnr TYPE posnr,
          matnr TYPE matnr,
          makt  TYPE makt, " structure with these fields: mandt, matnr, spras, maktx, maktg
        END OF ty.
DATA:
  it TYPE TABLE OF ty,
  wa TYPE ty.
*DATA: num TYPE vbap-vbeln. Not needed.

SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:
  num1 FOR vbap-vbeln. " You can use directly the field of the structure, because you used it in TABLES statement
SELECTION-SCREEN END OF BLOCK b.
DATA:
  it_fieldcat TYPE slis_t_fieldcat_alv,
  wa_fieldcat TYPE slis_fieldcat_alv.
*  layout      TYPE slis_layout_alv.  Delete ununsed variables

*DATA repid TYPE sy-repid.  Delete ununsed variables

START-OF-SELECTION.
  SELECT vbeln,
         posnr,
         matnr FROM vbap INTO TABLE @DATA(gt_vbap)
         WHERE vbeln IN @num1.
  IF sy-subrc EQ 0.
    SELECT matnr,
           maktx FROM makt INTO TABLE @DATA(gt_makt) FOR ALL ENTRIES IN @gt_vbap
           WHERE matnr EQ @gt_vbap-matnr.
    LOOP AT gt_vbap INTO DATA(wa_vbap).
      READ TABLE gt_makt INTO DATA(wa_makt) WITH KEY matnr = wa_vbap-matnr.
    ENDLOOP.
  ENDIF.

  wa_fieldcat-fieldname = 'VBELN'.
  wa_fieldcat-ref_tabname = 'VBAP'.
  wa_fieldcat-seltext_m = 'Accounting Document Number'.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.

  wa_fieldcat-fieldname = 'POSNR'.
  wa_fieldcat-ref_tabname = 'VBAP'.
  wa_fieldcat-seltext_m = 'Document Number'.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.

  wa_fieldcat-fieldname = 'MATNR'.
  wa_fieldcat-ref_tabname = 'VBAP'.
  wa_fieldcat-seltext_m = 'Number'.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.

  wa-maktx = |Doesn't exists|.
  wa-makt-maktx = 'Exists'.
  
  " There is no field MAKTX in your ty (check my comment there)
  wa_fieldcat-fieldname = 'MAKTX'.
  wa_fieldcat-ref_tabname = 'MAKT'.
  wa_fieldcat-seltext_m = 'Accoun Number'.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
*      i_callback_program = repid    If you don't fill repid, then don't use it
      i_grid_title       = 'ACCOUNTING DOCUMENT DETAILS'
      it_fieldcat        = it_fieldcat
    TABLES
      t_outtab           = it.

I added some comments to your code and some lines I have commented out.

When you copy the code into your editor and try to activate, you will get an error, because of line:

wa-maktx = |Doesn't exists|.

I hope this will help you to continue learning.

Greetings
Stephan

6 REPLIES 6

philipdavy
Contributor

Please convert these fields with in the quotes to capital letters .

wa_fieldcat-fieldname ='VBELN'. 

wa_fieldcat-ref_tabname ='VBAP'.

Do it for every field .

mateuszadamus
Active Contributor

Hi manoj16393

Your IT internal table is empty. You need to add some records to it. You can do it like this.

LOOP AT gt_vbap INTO DATA(wa_vbap).
  APPEND INITIAL LINE TO it REFERENCE INTO DATA(ld_it).
  MOVE-CORRESPONDING wa_vbap TO ld_it->*

  READ TABLE gt_makt INTO DATA(wa_makt) WITH KEY matnr = wa_vbap-matnr.
  CHECK sy-subrc = 0.
  ld_it->maktx = wa_makt-maktx.
ENDLOOP.


Regards,
Mateusz

PS: Comment made by philip.davy2 is also valid. You should have the fields' names in uppercase.

PPS: You also need to change your results type. Add field MAKTX instead of MAKT.

TYPES : BEGIN OF ty,
          vbeln TYPE vbeln,
          posnr TYPE posnr,
          matnr TYPE matnr,
          maktx TYPE maktx,
        END OF ty.

Sandra_Rossi
Active Contributor

Obvious error. The output is empty because IT is empty. Please debug your code before posting questions.

stekoester
Explorer

Hi Manoj,

you have to merge the data of vbap and makt into your output table "it" as philip.davy2, mateuszadamus and sandra.rossi already told.

I know that you started new in ABAP, but you have to start learning the basics in ABAP first. I gave this advise already in our telegram group as you know.

REPORT zmanoj3.
TABLES : vbap , makt.
TYPES : BEGIN OF ty,
          vbeln TYPE vbeln,
          posnr TYPE posnr,
          matnr TYPE matnr,
          makt  TYPE makt, " structure with these fields: mandt, matnr, spras, maktx, maktg
        END OF ty.
DATA:
  it TYPE TABLE OF ty,
  wa TYPE ty.
*DATA: num TYPE vbap-vbeln. Not needed.

SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:
  num1 FOR vbap-vbeln. " You can use directly the field of the structure, because you used it in TABLES statement
SELECTION-SCREEN END OF BLOCK b.
DATA:
  it_fieldcat TYPE slis_t_fieldcat_alv,
  wa_fieldcat TYPE slis_fieldcat_alv.
*  layout      TYPE slis_layout_alv.  Delete ununsed variables

*DATA repid TYPE sy-repid.  Delete ununsed variables

START-OF-SELECTION.
  SELECT vbeln,
         posnr,
         matnr FROM vbap INTO TABLE @DATA(gt_vbap)
         WHERE vbeln IN @num1.
  IF sy-subrc EQ 0.
    SELECT matnr,
           maktx FROM makt INTO TABLE @DATA(gt_makt) FOR ALL ENTRIES IN @gt_vbap
           WHERE matnr EQ @gt_vbap-matnr.
    LOOP AT gt_vbap INTO DATA(wa_vbap).
      READ TABLE gt_makt INTO DATA(wa_makt) WITH KEY matnr = wa_vbap-matnr.
    ENDLOOP.
  ENDIF.

  wa_fieldcat-fieldname = 'VBELN'.
  wa_fieldcat-ref_tabname = 'VBAP'.
  wa_fieldcat-seltext_m = 'Accounting Document Number'.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.

  wa_fieldcat-fieldname = 'POSNR'.
  wa_fieldcat-ref_tabname = 'VBAP'.
  wa_fieldcat-seltext_m = 'Document Number'.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.

  wa_fieldcat-fieldname = 'MATNR'.
  wa_fieldcat-ref_tabname = 'VBAP'.
  wa_fieldcat-seltext_m = 'Number'.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.

  wa-maktx = |Doesn't exists|.
  wa-makt-maktx = 'Exists'.
  
  " There is no field MAKTX in your ty (check my comment there)
  wa_fieldcat-fieldname = 'MAKTX'.
  wa_fieldcat-ref_tabname = 'MAKT'.
  wa_fieldcat-seltext_m = 'Accoun Number'.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
*      i_callback_program = repid    If you don't fill repid, then don't use it
      i_grid_title       = 'ACCOUNTING DOCUMENT DETAILS'
      it_fieldcat        = it_fieldcat
    TABLES
      t_outtab           = it.

I added some comments to your code and some lines I have commented out.

When you copy the code into your editor and try to activate, you will get an error, because of line:

wa-maktx = |Doesn't exists|.

I hope this will help you to continue learning.

Greetings
Stephan

0 Kudos

hi stephkoester,

i followe your steps but i am not getting data in output,

i copyed your code and rxcuted but still no output!!!

thanks advanced..!

0 Kudos

Hi manoj16393,

I haven't fixed your code so that you will get output. I gave some points to let you find the solution by yourself.

You have to make the changes that mateuszadamus mentioned in his answer. Implement both and you will get your output if data is selected from vbap.

Greetings
Stephan