Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

ALV Report.

HI,

I have 2 tables marc, and makt and from marc i have to take werks as parameter

and from makt we have select options matnr and maktx, then i have to show that option on a single alv report. I am having problem with the fetching of data and displaying. Does anybody have a program for this.

Tags:
Former Member
Former Member replied

Hi,

here it is your program....

REPORT test.

TABLES:
marc,
makt.
DATA: BEGIN OF imat OCCURS 100,
matnr LIKE marc-matnr, "Material number
maktx LIKE makt-maktx, "Material short text
END OF imat.

DATA i_repid LIKE sy-repid.
DATA i_lines LIKE sy-tabix.

TYPE-POOLS: slis.
DATA int_fcat TYPE slis_t_fieldcat_alv.

PARAMETERS : p_werks LIKE marc-werks.
SELECT-OPTIONS: s_matnr FOR marc-matnr.

START-OF-SELECTION.

  SELECT marc~matnr makt~maktx INTO CORRESPONDING FIELDS OF
  TABLE imat FROM marc INNER JOIN makt ON
  marc~matnr EQ makt~matnr WHERE marc~werks EQ p_werks
  AND marc~matnr IN s_matnr.

* Check if material was found
  CLEAR i_lines.
  DESCRIBE TABLE imat LINES i_lines.
  IF i_lines LT 1.
*   Using hardcoded write here for easy upload
    WRITE: /
    'No materials found.'.
    EXIT.
  ENDIF.

END-OF-SELECTION.
* Store report name
  i_repid = sy-repid.

* Create Fieldcatalogue from internal table
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      i_program_name         = i_repid
      i_internal_tabname     = 'IMAT'  "capital letters!
      i_inclname             = i_repid
    CHANGING
      ct_fieldcat            = int_fcat
    EXCEPTIONS
      inconsistent_interface = 1
      program_error          = 2
      OTHERS                 = 3.

  IF sy-subrc <> 0.
    WRITE: /
    'Returncode',
    sy-subrc,
    'from FUNCTION REUSE_ALV_FIELDCATALOG_MERGE'.
  ENDIF.

  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
      i_callback_program = i_repid
      it_fieldcat        = int_fcat
      i_save             = 'A'
    TABLES
      t_outtab           = imat
    EXCEPTIONS
      program_error      = 1
      OTHERS             = 2.

  IF sy-subrc <> 0.
    WRITE: /
    'Returncode',
    sy-subrc,
    'from FUNCTION REUSE_ALV_LIST_DISPLAY'.
  ENDIF.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question