Application Development and Automation 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: 
Read only

Datatype Conversion Problem in ALV

Former Member
0 Likes
1,573

Hi,

I am having problem in displaying the table contents in the ALV report. Particularly, I figured out that a pack(P) data type is not matching with the ALV catalogue.

I have defined internal table fields cr_amt and dr_amt as pack datatype.

BEGIN OF t_tab10,

slacc(9) type N,

slaccd(30),

dr_amt type p decimals 2,

cr_amt type p decimals 2,

vend(10),

vend_name(50), "Vend. name

reason(50), "reason

modified,

END OF t_tab10.

The values from database table of type( 15 DEC 2 decimals) are placed in these fields. Operation can be carried out successfully in the internal table fields. when I am trying to put the contents of these fields into ALV its produce a short dump into screen. If I clear these fields before sending it to ALV, it generates ALV output with initial values of these fields otherwise it produce shot-dump.

I used the following catalogue for these fields.

clear wa_fieldcat.

wa_FIELDCAT-fieldname = 'DR_AMT'.

wa_FIELDCAT-inttype = 'P'.

wa_FIELDCAT-outputlen = 15.

wa_FIELDCAT-decimals = 2.

wa_FIELDCAT-coltext = 'Dr. Amount'.

wa_FIELDCAT-TOOLTIP = 'Montant dépôt'.

append wa_fieldcat to pt_fieldcat.

clear wa_fieldcat.

wa_FIELDCAT-fieldname = 'CR_AMT'.

wa_FIELDCAT-inttype = 'P'.

wa_FIELDCAT-outputlen = 17. "15

wa_FIELDCAT-decimals = 2.

wa_FIELDCAT-coltext = 'Cr. Amount'.

wa_FIELDCAT-TOOLTIP = 'Montant Crédit'.

append wa_fieldcat to pt_fieldcat.

Thanks

Lokman

9 REPLIES 9
Read only

FredericGirod
Active Contributor
0 Likes
1,124

Hi,

use the function module : LVC_FIELDCATALOG_MERGE

you will see how SAP set data into fieldcatalog.

(that could be maybe the currency)

Rgd

Frédéric

Read only

0 Likes
1,124

Please adjust as the following.



clear wa_fieldcat.
wa_FIELDCAT-fieldname = 'DR_AMT'.
<b>wa_FIELDCAT-datatype = 'QUAN'.</b>
wa_FIELDCAT-outputlen = 15.
wa_FIELDCAT-decimals = 2.
wa_FIELDCAT-coltext = 'Dr. Amount'.
wa_FIELDCAT-TOOLTIP = 'Montant dépôt'.
append wa_fieldcat to pt_fieldcat.

clear wa_fieldcat.
wa_FIELDCAT-fieldname = 'CR_AMT'.
<b>wa_FIELDCAT-datatype = 'QUAN'.</b>
wa_FIELDCAT-outputlen = 17. "15
wa_FIELDCAT-decimals = 2.
wa_FIELDCAT-coltext = 'Cr. Amount'.
wa_FIELDCAT-TOOLTIP = 'Montant Crédit'.
append wa_fieldcat to pt_fieldcat.



Regards,

Rich Heilman

Read only

0 Likes
1,124

Heilman,

I tried with datatype "QUAN but it seems the same result. I don't know is there any mismatch of length?

Lokman

Read only

0 Likes
1,124

Try increasing the length to 18 and check

Read only

0 Likes
1,124

Hi,

try giving this also.....

<b>fieldcat-ref_fieldname = "REFFIELD'.

fieldcat-ref_tabname = 'REFTAB'.</b>

regards

vijay

Read only

0 Likes
1,124

Can you please include the name of your internal table.



clear wa_fieldcat.
wa_FIELDCAT-fieldname = 'DR_AMT'.
<b>wa_FIELDCAT-tabname = 'ITAB'.
wa_FIELDCAT-datatype = 'QUAN'.</b>
wa_FIELDCAT-outputlen = 15.
wa_FIELDCAT-decimals = 2.
wa_FIELDCAT-coltext = 'Dr. Amount'.
wa_FIELDCAT-TOOLTIP = 'Montant dépôt'.
append wa_fieldcat to pt_fieldcat.



REgards,

RIch Heilman

Read only

0 Likes
1,124

Hi ,

Try by adding reference field and table:

For your Qty field:

WA_fieldcat-ref_fieldname = Reference Field. Ex: MENGE

WA_fieldcat-ref_tabname = Reference table. Ex: EKPO

Lanka

Read only

Former Member
0 Likes
1,124

Hi,

Frédéric is correct for Qty and currency you have to maintain data in the reference tables.

Lanka

Check field Catalog:

currency(5) type c,

cfieldname type slis_fieldname, " field with currency unit

ctabname type slis_tabname, " and table

ifieldname type slis_fieldname, " initial column

quantity(3) type c,

qfieldname type slis_fieldname, " field with quantity unit

qtabname type slis_tabname, " and table

Regards,

Lanka

Read only

alejandro_lpez
Contributor
0 Likes
1,124

Hi,

Try with datatype "CURR".

regards,

Alejandro.