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: 

Lost leading zeros of material in spool but getting in ALV output

Former Member
0 Kudos

Hi ,

I am trying to run a report in background, In spool I dont have leading zeros of material

When I run report in foreground I am getting leading zeros in my alv report.

Could you Please help me out.

Thank in advance

1 ACCEPTED SOLUTION

former_member182915
Active Contributor
0 Kudos

Hi,

do the changes

1. for the field values truncated

wa_fieldcat-no_convext = 'X'.

2.in

       i_grid_settings = lwa_grid

      is_layout       = lwa_layout


*Optimize column width in the layout
  lwa_layout-colwidth_optimize = 'X'.

*Do not optimize column width for printing
  lwa_grid-no_colwopt = 'X'.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_grid_settings = lwa_grid
      is_layout       = lwa_layout
      it_fieldcat     = gt_fieldcat
    TABLES
      t_outtab        = gt_out
    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.

7 REPLIES 7

Hvshal4u
Active Participant
0 Kudos

Hi,

When you display the ALV the material no. is automatically converted to external form due to the conversion routines applied. When  you run the alv in background the material no. is in internal format.

Regards-

Vishal

Former Member
0 Kudos

Thanks for ur reply

I knew it,Spool is in internal format.

How can we get leading zeros now

Former Member
0 Kudos

Pass the reference field name and reference table name to the fieldcat as MATNR and MARA respectively.

The fields in the fieldcat are  ref_fieldname and  ref_tabname.

V.

Hvshal4u
Active Participant
0 Kudos

Hi,

One way to do this is to take another field of char 20-18  in your final internal which you are using in ALV and assign the MATNR  to this field so the conversion routine will not be applies to this. Then you can pass

Regards-

Vishal

former_member182915
Active Contributor
0 Kudos

Hi,

do the changes

1. for the field values truncated

wa_fieldcat-no_convext = 'X'.

2.in

       i_grid_settings = lwa_grid

      is_layout       = lwa_layout


*Optimize column width in the layout
  lwa_layout-colwidth_optimize = 'X'.

*Do not optimize column width for printing
  lwa_grid-no_colwopt = 'X'.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_grid_settings = lwa_grid
      is_layout       = lwa_layout
      it_fieldcat     = gt_fieldcat
    TABLES
      t_outtab        = gt_out
    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.

0 Kudos

Hi,

Try the options Leading Zeros or Supres Zero's in Field Catalog.

Former Member
0 Kudos

Hi,

  Try to set this flag in the fieldcat:

  no_zero = 'X'.

  Or try to assign value to ref_fieldname and ref_tabname in the fieldcat.

  Hope this helps.