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: 

ALV: ADD leading ZEROs in a CHAR field

Former Member

Hello Everybody!

I have a problem and I hope you can help me

What I have:

1. ALV (hier)

2. Char field 'DEBIT' type SAKNR.

3. Field catalog TYPE slis_t_fieldcat_alv,

created by FUNCTION MODULE 'REUSE_ALV_FIELDCATALOG_MERGE'.

The problem is: i need to show leading zeros in ALV.

For example: an account '07110000' (in the inner table) is shown as '7110000'.

What I've done:

1. ls_fieldcat-lzero = 'X'.

ls_fieldcat-no_convext = 'X'.

2. CLEAR ls_fieldcat-ref_tabname.

ls_fieldcat-lzero = 'X'.

( ls_fieldcat-ref_fieldname was clear after filling by the function module)

I'm realy waiting for your advice!

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

try this way, you will get.

SAKNR(10) TYPE n,

Regs

Srinivas

11 REPLIES 11

Former Member
0 Kudos

Hi

LZERO works rlevant only to fields of data type NUMC. In the default setting, the ALV Grid Control displays these fields right justified without leading zeros. If you set LZERO, leading zeros are displayed.

SAKNR is having conversion exit CONVERSION_EXIT_ALPHA_OUTPUT.

Regards

Shiva

0 Kudos

I know that SAKNR has conversion exit CONVERSION_EXIT_ALPHA_OUTPUT, but what shall I do with it to cancel this conversion??

Former Member
0 Kudos

Hi

try this way, you will get.

SAKNR(10) TYPE n,

Regs

Srinivas

0 Kudos

Try this may work:

ls_fieldcat-lzero = 'X'.

ls_fieldcat-datatype = 'NUMC'.

0 Kudos

>

> Hi

>

> try this way, you will get.

> SAKNR(10) TYPE n,

>

>

> Regs

>

> Srinivas

It's impossible, because SAKNR can be 'Z0070000'.

former_member404244
Active Contributor
0 Kudos

Hi,

try to give refernce table name and reference field name for the field after the fieldcatalog merge FM.

i mean to say modify the fieldcatalog for that particluar field by giving refernce table name and reference field name .

or use conversion_exit_alpha_input to add zero's to it.

Regards,

Nagaraj

0 Kudos

>

> Hi,

>

> try to give refernce table name and reference field name for the field after the fieldcatalog merge FM.

>

> i mean to say modify the fieldcatalog for that particluar field by giving refernce table name and reference field name .

I've tried it, but it doesn't work:

ls_fieldcat-outputlen = 8.

ls_fieldcat-lzero = 'X'.

ls_fieldcat-no_convext = 'X'.

ls_fieldcat-ref_tabname = 'T599I'.

ls_fieldcat-ref_fieldname = 'PARAM'.

ls_fieldcat-datatype = 'NUMC'.

ls_fieldcat-inttype = 'N'.

>

> or use conversion_exit_alpha_input to add zero's to it.

>

> Regards,

> Nagaraj

How can I use conversion_exit_alpha_input? I have no idea...

0 Kudos

Hi,

The reference table and field name u specified are wrong

try this

ls_fieldcat-outputlen = 8.

ls_fieldcat-lzero = 'X'.

ls_fieldcat-no_convext = 'X'.

ls_fieldcat-ref_tabname = 'SKA1'.

ls_fieldcat-ref_fieldname = 'SAKNR'.

Regards,

Nagaraj

0 Kudos

>

> Hi,

>

> The reference table and field name u specified are wrong

>

> try this

>

> ls_fieldcat-outputlen = 8.

> ls_fieldcat-lzero = 'X'.

> ls_fieldcat-no_convext = 'X'.

> ls_fieldcat-ref_tabname = 'SKA1'.

> ls_fieldcat-ref_fieldname = 'SAKNR'.

>

> Regards,

> Nagaraj

Thanks for advice, but I referenced to...

ls_fieldcat-ref_tabname = 'T599I'.

ls_fieldcat-ref_fieldname = 'PARAM'.

...because I tried to cancel conversion exit CONVERSION_EXIT_ALPHA_OUTPUT.

Field 'PARAM' doesn't have conversion exit and has the same type like 'SAKNR'.

Former Member
0 Kudos

ACTUALLY, I'm very embarrassed now, because ALL YOU, who advised me to use NO_CONVEXT was RIGHT!!!

This way is correct:

LOOP AT gt_fieldcat INTO ls_fieldcat
    WHERE fieldname = 'DEBIT' OR fieldname = 'CREDIT'.
      ls_fieldcat-no_convext = 'X'.
    MODIFY gt_fieldcat FROM ls_fieldcat. "TRANSPORTING fieldname lzero outputlen ref_tabname.
  ENDLOOP

.

My mistake was: I used TRANSPORTING (you can see it from my code) and I had forgoten about it. Sorry! If only I wasn't so absent-minded today...:(

Thank YOU very very much!!!

Edited by: Svetlana Bykova on Dec 22, 2008 6:46 AM

Former Member
0 Kudos

Use NO_CONVEXT = 'X'.