Skip to Content
-6

Not fetching fields

Even after giving the proper code the select statement is fetching fields for only plant field name - werks

SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S31 { font-style: italic; color: #808080; } .L0S32 { color: #3399FF; } .L0S33 { color: #4DA619; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; } .L0S70 { color: #808080; }


*&---------------------------------------------------------------------*
*& Report ZMMPRG1
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZMMPRG1.

tables:mseg,kna1,t001w,makt,mara,marc.
types: begin of ty_mara,
matnr type mara-matnr,
werks type marc-werks,
end of ty_mara,
BEGIN OF ty_marc,
matnr TYPE mara-matnr,
werks TYPE marc-werks,
end of ty_marc,
begin of ty_mseg,
matnr type mara-matnr,
werks type marc-werks,
charg type mseg-charg,
menge type mseg-menge,
meins type mseg-meins,
ebeln type mseg-ebeln,
ebelp type mseg-ebelp,
budat_mkpf type mseg-budat_mkpf,
mblnr type mseg-mblnr,
zeile type mseg-zeile,
bwart type mseg-bwart,
lbkum type mseg-lbkum,
bukrs type mseg-bukrs,
kunnr type mseg-kunnr,
vbelp_im type mseg-vbelp_im,
vbeln_im type mseg-vbeln_im,
shkzg type mseg-shkzg,
dmbtr type mseg-dmbtr,
end of ty_mseg,
begin of ty_makt,
maktx type makt-maktx,
spras type makt-spras,
matnr type mara-matnr,
end of ty_makt,
begin of ty_t001w,
name1 type t001w-name1,
werks type mseg-werks,
end of ty_t001w,
begin of ty_kna1,
kunnr type kna1-kunnr,
name1 type t001w-name1,
end of ty_kna1,
begin of ty_final,
matnr type mseg-matnr,
werks type mseg-werks,
maktx type makt-maktx,
name1 type t001w-name1,
charg type mseg-charg,
menge type mseg-menge,
meins type mseg-meins,
ebeln type mseg-ebeln,
ebelp type mseg-ebelp,
budat_mkpf type mseg-budat_mkpf,
mblnr type mseg-mblnr,
zeile type mseg-zeile,
bwart type mseg-bwart,
lbkum type mseg-lbkum,
bukrs type mseg-bukrs,
kunnr type mseg-kunnr,
vbelp_im type mseg-vbelp_im,
vbeln_im type mseg-vbeln_im,
shkzg type mseg-shkzg,
dmbtr type mseg-dmbtr,
spras type makt-spras,
end of ty_final.

DATA: it_mseg type standard table of ty_mseg,
wa_mseg type ty_mseg,
it_marc type standard table of ty_marc,
wa_marc type ty_marc,
it_makt type standard table of ty_makt,
wa_makt type ty_makt,
it_t001w type standard table of ty_t001w,
wa_t001w type ty_t001w,
it_kna1 type standard table of ty_kna1,
wa_kna1 type ty_kna1,
it_mara type standard table of ty_mara,
wa_mara type ty_mara,
it_final TYPE STANDARD TABLE OF ty_final,
wa_final TYPE ty_final,
fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
select-options:
s_bukrs for mseg-bukrs obligatory,
s_werks for mseg-werks obligatory,
s_budat for mseg-budat_mkpf.
START-OF-SELECTION.
PERFORM sr_data_retrivel.
PERFORM sr_build_fieldcatalog.
PERFORM sr_display_alv_report.
FORM sr_data_retrivel .

* SELECT matnr werks FROM mseg INTO corresponding fields of TABLE it_mseg for all entries in it_marc where werks = it_marc-werks.
select matnr werks charg menge meins ebeln ebelp mblnr zeile bwart lbkum from mseg into corresponding fields of table it_mseg for all entries in it_marc where werks = it_marc-werks and matnr = it_marc-matnr.
sort it_mseg.
if sy-subrc = 0.
select matnr maktx from makt into corresponding fields of table it_makt for all entries in it_marc where matnr = it_marc-matnr.
endif.
sort it_makt.
if sy-subrc = 0.
select kunnr name1 from kna1 into corresponding fields of table it_kna1 for all entries in it_mseg where kunnr = it_mseg-kunnr.
endif.
sort it_kna1.

LOOP at IT_MSEG into WA_MSEG.
IF WA_MSEG-SHKZG = 'H'.
WA_MSEG-DMBTR = WA_MSEG-DMBTR * +1.
wa_mseg-dmbtr = 'S'.
wa_mseg-dmbtr = wa_mseg-dmbtr * -1.
WA_MSEG-MENGE = WA_MSEG-MENGE * wa_mseg-dmbtr.
ENDIF.
MODIFY IT_MSEG FROM WA_MSEG TRANSPORTING DMBTR MENGE.
READ TABLE it_mseg INTO wa_mseg WITH KEY werks = wa_mseg-werks.
if sy-subrc = 0.
wa_final-matnr = wa_mseg-matnr.
wa_final-werks = wa_mseg-werks.
wa_final-maktx = wa_makt-maktx.
wa_final-charg = wa_mseg-charg.
wa_final-menge = wa_mseg-menge.
wa_final-meins = wa_mseg-meins.
wa_final-zeile = wa_mseg-zeile.
wa_final-bwart = wa_mseg-bwart.
wa_final-lbkum = wa_mseg-lbkum.
wa_final-ebeln = wa_mseg-ebeln.
wa_final-ebelp = wa_mseg-ebelp.
wa_final-mblnr = wa_mseg-mblnr.
wa_final-kunnr = wa_kna1-kunnr.
wa_final-vbeln_im = wa_mseg-vbeln_im.
wa_final-vbelp_im = wa_mseg-vbelp_im.

READ TABLE it_makt INTO wa_makt WITH KEY maktx = wa_makt-maktx.
IF sy-subrc = 0.
wa_final-maktx = wa_makt-maktx.
ENDIF.
read table it_t001w into wa_t001w with key name1 = wa_kna1-name1 .
wa_final-name1 = wa_t001w-name1.
endif.
endloop.
APPEND wa_final TO it_final.
ENDFORM.

FORM sr_build_fieldcatalog .
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 20.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'WERKS'.
fieldcatalog-seltext_m = 'Plant'.
fieldcatalog-col_pos = 1.
fieldcatalog-outputlen = 20.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MAKTX'.
fieldcatalog-seltext_m = 'Description'.
fieldcatalog-col_pos = 2.
fieldcatalog-outputlen = 20.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'NAME1'.
fieldcatalog-seltext_m = 'Plant Description'.
fieldcatalog-col_pos = 3.
fieldcatalog-outputlen = 20.
APPEND fieldcatalog TO fieldcatalog.
fieldcatalog-fieldname = 'CHARG'.
fieldcatalog-seltext_m = 'Batch'.
fieldcatalog-col_pos = 4.
fieldcatalog-outputlen = 20.
APPEND fieldcatalog TO fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'Quantity'.
fieldcatalog-col_pos = 5.
fieldcatalog-outputlen = 20.
APPEND fieldcatalog TO fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Base Unit'.
fieldcatalog-col_pos = 6.
fieldcatalog-outputlen = 20.
APPEND fieldcatalog TO fieldcatalog.
fieldcatalog-fieldname = 'ebeln'.
fieldcatalog-seltext_m = 'Purchase order number'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 30.
APPEND fieldcatalog TO fieldcatalog.
fieldcatalog-fieldname = 'ebelp'.
fieldcatalog-seltext_m = 'Item Number of Purchasing Document'.
fieldcatalog-col_pos = 8.
fieldcatalog-outputlen = 30.
APPEND fieldcatalog TO fieldcatalog.
fieldcatalog-fieldname = 'BUDAT_MKPF'.
fieldcatalog-seltext_m = 'Posting date'.
fieldcatalog-col_pos = 9.
fieldcatalog-outputlen = 20.
APPEND fieldcatalog TO fieldcatalog.
fieldcatalog-fieldname = 'MBLNR'.
fieldcatalog-seltext_m = 'GR Number'.
fieldcatalog-col_pos = 10.
fieldcatalog-outputlen = 30.
APPEND fieldcatalog TO fieldcatalog.
fieldcatalog-fieldname = 'zeile'.
fieldcatalog-seltext_m = 'Item in material document'.
fieldcatalog-col_pos = 11.
fieldcatalog-outputlen = 30.
APPEND fieldcatalog TO fieldcatalog.
fieldcatalog-fieldname = 'bwart'.
fieldcatalog-seltext_m = 'Movement type'.
fieldcatalog-col_pos = 12.
fieldcatalog-outputlen = 30.
APPEND fieldcatalog TO fieldcatalog.
fieldcatalog-fieldname = 'lbkum'.
fieldcatalog-seltext_m = 'Opening stock'.
fieldcatalog-col_pos = 13.
fieldcatalog-outputlen = 10.
APPEND fieldcatalog TO fieldcatalog.
fieldcatalog-fieldname = 'kunnr'.
fieldcatalog-seltext_m = 'Account number of customer'.
fieldcatalog-col_pos = 14.
fieldcatalog-outputlen = 10.
APPEND fieldcatalog TO fieldcatalog.
fieldcatalog-fieldname = 'vbeln_im'.
fieldcatalog-seltext_m = 'Delivery number'.
fieldcatalog-col_pos = 15.
fieldcatalog-outputlen = 30.
APPEND fieldcatalog TO fieldcatalog.
fieldcatalog-fieldname = 'vbelv_im'.
fieldcatalog-seltext_m = 'Delivery number'.
fieldcatalog-col_pos = 16.
fieldcatalog-outputlen = 10.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
ENDFORM.

FORM sr_display_alv_report .
gd_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
it_fieldcat = fieldcatalog[]
i_save = 'X'
TABLES
t_outtab = it_final
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Oct 25, 2019 at 08:30 AM

    Hi Nidhi,

    Please use CODE formatter to put your code.

    If you see WERKS data, you should see MATNR data as well. Can you change col_pos for MATNR to any value other than '0' and see if it appears. If yes, then please debug the program and see where you are missing data. That is where your fix is.

    Regards

    GK

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 25, 2019 at 08:07 AM

    Hi Nidhi,

    You are not populating internal table "LT_MARC". I am unable to see any code which is population to the mentioned table.

    Thanks,

    Gourab

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 25, 2019 at 09:17 AM
    -2

    I have debugged it.

    Data is there but fetching values from only one field.

    tried the col-pos thing also but did not work

    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.