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: 

Header text not printing correctly in ALV

Former Member
0 Kudos

Hi all,

I am facing a problem in ALV. My requirment is to display material document number, material ,header and other corresponding fields in ALV.

I am able to display all the required fields in ALV but the problem is with header text. Initially, the requirement was to display Header text as the first column in ALV. But it was going for dump. When i changed it as second column in the ALV, i am able to view the output.

1. Is there any constraint in ALV that Texts should not be the first column?

2. Second, the texts in header field are getting overwritten if i move it to the second column.

For example, If i have the XBLNR as the first column, contents of XBLNR gets displayed in header text(BKTXT) column, If i make the header text as third column and have Number of BIll Lading (FRBNR) as the second column then all the contents of FRBNR gets displayed in BKTXT.

For some reason,it is not displaying the contents of BKTXT. I kept a break point just before REUSE_ALV_GRID_DISPLAY and i am able to see the header texts in my internal table. It is just that in the output it somehow overwrites and i am not able to figure it out.

Note : There are no issue with field catalog. The alignment of both field catalog and my internal table are exact.

Looking forward for your help. Thanks.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Ankur,

Thanks for your reply. IF i have BKTXT as the first column,it goes for dump but if i change the column position as second( Without changing any other entry in field catalog) it works perfectly fine.

But now the client has agreed to have it as second column, my main problem now is to identify why the header texts are overwritten by the first column's data.

Can you please help me with that? I have also attached my field catalog along with this.

DATA: wl_fieldcatalog TYPE slis_fieldcat_alv.

  • Building of field catalog

wl_fieldcatalog-fieldname = c_xblnr.

wl_fieldcatalog-seltext_l = text-003.

wl_fieldcatalog-col_pos = 1.

wl_fieldcatalog-key = ''.

wl_fieldcatalog-outputlen = 1.

APPEND wl_fieldcatalog TO it_fieldcatalog.

CLEAR wl_fieldcatalog.

wl_fieldcatalog-fieldname = c_bktxt.

wl_fieldcatalog-seltext_l = text-002.

wl_fieldcatalog-col_pos = 2.

wl_fieldcatalog-input = c_x.

wl_fieldcatalog-key = ''.

wl_fieldcatalog-outputlen = 1.

APPEND wl_fieldcatalog TO it_fieldcatalog.

CLEAR wl_fieldcatalog.

If i make BKTXT as the third column and make FRBTR as the second column( I have not displayed all field catalog's here as it would be confusing) then FRBTR entry gets updated in BKTXT.

8 REPLIES 8

former_member555112
Active Contributor
0 Kudos

Hi,

I tried doing your requirment.

But it runs correctly.

Probably you need to check your field-catalog only.

I have my code as follows:-

You can test this report.

REPORT  ztestank.
TYPE-POOLS : slis.
PARAMETERS : p_mbln TYPE mblnr.
TYPES: BEGIN OF y_t_mseg,
       mblnr TYPE mblnr,
       bktxt TYPE bktxt,
       matnr TYPE matnr,
       END OF y_t_mseg.
DATA : it_mseg TYPE STANDARD TABLE OF y_t_mseg.
DATA : wa_mseg TYPE y_t_mseg.
DATA : wa_fcat TYPE slis_fieldcat_alv.
DATA : it_fcat TYPE slis_t_fieldcat_alv.
DATA : lv_repid TYPE syrepid.
START-OF-SELECTION.

  SELECT SINGLE h~mblnr h~bktxt l~matnr
  INTO CORRESPONDING FIELDS OF wa_mseg
  FROM mkpf AS h INNER JOIN mseg AS l
  ON  h~mblnr = l~mblnr
  AND h~mjahr = l~mjahr
  WHERE h~mblnr =  p_mbln.
  IF sy-subrc EQ 0.
    APPEND wa_mseg TO it_mseg.
  ENDIF.

END-OF-SELECTION.

* prepare fcat
  wa_fcat-col_pos       = '1'.
  wa_fcat-fieldname     = 'BKTXT'.
  wa_fcat-ref_fieldname = 'BKTXT'.
  wa_fcat-ref_tabname   = 'MKPF'.
  APPEND   wa_fcat TO it_fcat.

  wa_fcat-col_pos       = '2'.
  wa_fcat-fieldname     = 'MBLNR'.
  wa_fcat-ref_fieldname = 'MBLNR'.
  wa_fcat-ref_tabname   = 'MKPF'.
  APPEND   wa_fcat TO it_fcat.

  wa_fcat-col_pos       = '3'.
  wa_fcat-fieldname     = 'MATNR'.
  wa_fcat-ref_fieldname = 'MATNR'.
  wa_fcat-ref_tabname   = 'MSEG'.
  APPEND   wa_fcat TO it_fcat.

  MOVE sy-repid TO  lv_repid.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program = lv_repid
      it_fieldcat        = it_fcat
    TABLES
      t_outtab           = it_mseg
    EXCEPTIONS
      program_error      = 1
      OTHERS             = 2.
  IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

Regards,

Ankur Parab

Former Member
0 Kudos

Hi Ankur,

Thanks for your reply. IF i have BKTXT as the first column,it goes for dump but if i change the column position as second( Without changing any other entry in field catalog) it works perfectly fine.

But now the client has agreed to have it as second column, my main problem now is to identify why the header texts are overwritten by the first column's data.

Can you please help me with that? I have also attached my field catalog along with this.

DATA: wl_fieldcatalog TYPE slis_fieldcat_alv.

  • Building of field catalog

wl_fieldcatalog-fieldname = c_xblnr.

wl_fieldcatalog-seltext_l = text-003.

wl_fieldcatalog-col_pos = 1.

wl_fieldcatalog-key = ''.

wl_fieldcatalog-outputlen = 1.

APPEND wl_fieldcatalog TO it_fieldcatalog.

CLEAR wl_fieldcatalog.

wl_fieldcatalog-fieldname = c_bktxt.

wl_fieldcatalog-seltext_l = text-002.

wl_fieldcatalog-col_pos = 2.

wl_fieldcatalog-input = c_x.

wl_fieldcatalog-key = ''.

wl_fieldcatalog-outputlen = 1.

APPEND wl_fieldcatalog TO it_fieldcatalog.

CLEAR wl_fieldcatalog.

If i make BKTXT as the third column and make FRBTR as the second column( I have not displayed all field catalog's here as it would be confusing) then FRBTR entry gets updated in BKTXT.

0 Kudos

Hi,

Can you just show how you have declared your internal table?

Regards,

Ankur Parab

0 Kudos

types : begin of tp_final,

xblnr TYPE mkpf-xblnr,

bktxt TYPE mkpf-bktxt,

frbnr TYPE mkpf-frbnr,

matnr TYPE mseg-matnr,

end of tp_final.

data : it_final type standard table of tp_final.

0 Kudos

Hi,

Can you show your select query?

Regards,

Ankur Parab

0 Kudos

SELECT amblnr avgart a~blart

ablaum abktxt axblnr afrbnr

b~matnr

FROM mkpf AS a

INNER JOIN mseg AS b

ON amblnr = bmblnr

AND amjahr = bmjahr

INTO TABLE it_mkpf_final

FOR ALL ENTRIES IN it_mseg

WHERE a~mblnr EQ it_mseg-mblnr

AND a~mjahr EQ it_mseg-mjahr

AND b~bwart EQ '101'

AND b~matnr EQ it_mseg-matnr.

Apart from these, values for other movement types are also calculated and all are finally moved to an internal table.

LOOP AT it_mkpf_final INTO wa_mkpf_final.

wa_final-xblnr = wa_mkpf_final-xblnr.

wa_final-bktxt = wa_mkpf_final-bktxt.

wa_final-frbnr = wa_mkpf_final-frbnr.

append wa_final to it_final.

endloop.

0 Kudos

Hi,

At the moment everything seems to be fine.

I really do not understand why you are facing this problem.

Probably if you could send the entire code then can check it out.

But i feel that the problem will be in fieldcatalog and your final internal table only.

Regards,

Ankur Parab

0 Kudos

Ankur, it is working correctly now. It was so so stupid of me to have given the wrong field name. In constant C_BKTXT i had used BKTKT insted of BKTXT.

Just found it and on changing it works perfectly fine. I should have checked this long time back.

Thanks a lot for your time Ankur.