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: 

Leading zeros in CHAR-column of CL_GUI_ALV_GRID

hubert_heitzer
Contributor
0 Kudos

Hi,

I want to display a sequence of positions in an CL_GUI_ALV_GRID-object. The positions are separated by '-' character.

Type of the sequence column is CHAR49.

How can I desplay leading zeros in this column.

Example: I want 0190-0100-0650 to be desplayed instead of 190-0100-0650.

lvc_s_fcat-lzero = 'X' seems only to work with NUMC.

Kind Regards,

Hubert

1 ACCEPTED SOLUTION

SimoneMilesi
Active Contributor
0 Kudos

As usually, what did you try? You just concatenate the values? There is any exit active? How did you declare the fields you are concatenating?

with this code


REPORT zzzzzzzzzzzzzzz.

PARAMETERS: p_char TYPE char05 OBLIGATORY.

DATA: line(49) TYPE c,

       t_out TYPE TABLE OF line.

DATA alv TYPE REF TO cl_salv_table.

START-OF-SELECTION.

   CONCATENATE p_char '-' p_char '-' p_char '-' p_char INTO line.

   APPEND line TO t_out.

   cl_salv_table=>factory(

   IMPORTING

     r_salv_table = alv

   CHANGING

     t_table      = t_out ).

   alv->display( ).

i got this result

And the output

It's true i'm using CL_SALV_TABLE, but i do not think behaviour changes (but i'll give a try)

9 REPLIES 9

SimoneMilesi
Active Contributor
0 Kudos

As usually, what did you try? You just concatenate the values? There is any exit active? How did you declare the fields you are concatenating?

with this code


REPORT zzzzzzzzzzzzzzz.

PARAMETERS: p_char TYPE char05 OBLIGATORY.

DATA: line(49) TYPE c,

       t_out TYPE TABLE OF line.

DATA alv TYPE REF TO cl_salv_table.

START-OF-SELECTION.

   CONCATENATE p_char '-' p_char '-' p_char '-' p_char INTO line.

   APPEND line TO t_out.

   cl_salv_table=>factory(

   IMPORTING

     r_salv_table = alv

   CHANGING

     t_table      = t_out ).

   alv->display( ).

i got this result

And the output

It's true i'm using CL_SALV_TABLE, but i do not think behaviour changes (but i'll give a try)

0 Kudos

As i stated, no changes in the behaviour using CL_ALV_GUI_GRID

0 Kudos

Hi Simone,

yes, I just concatenate the values.

Type of the column in table to be desplayed an in fieldcatalog is data element Z_STL_POS_SEQU which is build from domain Z_POS_SEQU_10 (datatype CHAR49, no conversion exit).

I am concatenating as follows:

LOOP ... .

  ...

  CONCATENATE <Z_STL_POS_SEQU> '-' <RESB-POSNR (which is CHAR4)> INTO <Z_STL_POS_SEQU>

  ...

ENDLOOP.

Do you have any other hints?

Regards,

Hubert

0 Kudos

And you checked <Z_STL_POS_SEQU> which value contains when you do the CONCATENATE, right? (sorry, it's the only thing coming in mind).

0 Kudos

Debugger says column of <Z_STL_POS_SEQU> contains

0100

0190-0020-0100

0190-0030-0190-0020-0100

0170-0190-0030-0190-0020-0100

in fieldcatalogue field <Z_STL_POS_SEQU> is described as:

   lv_col_pos        = lv_col_pos + 1.
  ls_fcat-fieldname = 'STL_POS_SEQU'.
  ls_fcat-ref_table = 'ZPSPELEM_BEST'.       " \ data element
  ls_fcat-ref_field = 'STL_POS_SEQU'.          " / Z_STL_POS_SEQU
  ls_fcat-outputlen = 10.
  ls_fcat-coltext   = 'Sequenz StlPos'.
  ls_fcat-col_pos   = lv_col_pos.
  ls_fcat-just      = 'L'.
  ls_fcat-lzero     = abap_true.
  APPEND ls_fcat TO lt_fcat.
  ls_fcat-lzero     = abap_false.

0 Kudos

And field STL_POS_SEQU in your table ZPSPELEM_BEST how is defined?

Try to comment the REF_TABLE and REF_FIELD in your fieldcat, activate your report, run BCALV_BUFFER_DEL_SHARED to delete buffers and re-run your report

Message was edited by: Simone Milesi

0 Kudos

Transparent table ZPSPELEM_BEST (see field no. 3):

MANDT                   MANDT                    CLNT      3    0    Mandant

PS_PSP_PNR        PS_PSP_PNR         NUMC     8    0    PSP-Element

STL_POS_SEQU  Z_STL_POS_SEQU  CHAR    49   0    Sequenz 10 StlPos

...

0 Kudos

Hi,

If every time your field have 4 character then use conversion routine before concatenate the value with separate '-'. I hope it will help you.

Cheers,

John

0 Kudos

Thanks a lot!

I just had to take out both values for REF_TABLE and REF_FIELD.

Buffer deletion was not necessary.


Best regards,

Hubert