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: 

Runtime error in Dynamic internal table with AMOUNT and Quantity Fields..

Former Member
0 Kudos

Dear friends,

I am attempting write a dymanic Select Statement (with joins).

And the sleect query looks like this..


  SELECT (LT_SEL_LIST)
  INTO CORRESPONDING FIELDS OF
  TABLE <DYN_TABLE>
  FROM (LT_FROM_LIST)
  WHERE (LT_WHERE3).

Here the into table is a dynamically created internal table..

which is created by ...this


CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
    EXPORTING
      IT_FIELDCATALOG = IT_OUTPUT2[]
    IMPORTING
      EP_TABLE        = DY_TABLE.

the it_output2 contains the the fieldcatlog information of dynamically given fields :-

like:-


       TABNAME
       FIELDNAME
       DATATYPE
       LENG
       INTTYPE
       ROLLNAME
       DECIMALS
       REFTABLE
       REFFIELD

i mean the internal table is constructed with reference to all the bove metadata.

Problem:- This query run fine with all the fields Except AMOUNT AND QUANTITY fields....

When the selection list contain VBAK-NETWR or MSEG-MENGE..It throws a runtime error.

"The data read during a SLECT access couldnt be inserted into the target field,either conversion is not supported for

the target field's type or the target field is too short."

after this I even tried to construct the dynamic table with CFILEDNAME and QFIELDNAME in the Fieldcatalog.

so now my fieldcatlog looks like this:---


LOOP AT IT_DD03L..
  IF IT_DD03L-DATATYPE = 'CURR'.
       TABLEFIELD-CFIELDNAME = IT_DD03L-FIELDNAME .
       ENDIF.

   IF IT_FIELDCAT3-DATATYPE = 'QUAN'.
       TABLEFIELD-QFIELDNAME = IT_DD03L-FIELDNAME .
  ENDIF.
       TABLEFIELD-TABNAME     = IT_DD03L-TABNAME.
       TABLEFIELD-FIELDNAME   = IT_DD03L-FIELDNAME.
       TABLEFIELD-DATATYPE    = IT_DD03L-DATATYPE.
       TABLEFIELD-INTLEN      = IT_DD03L-LENG.
       TABLEFIELD-INTTYPE     = IT_DD03L-INTTYPE .
       TABLEFIELD-ROLLNAME    = IT_DD03L-ROLLNAME.
       TABLEFIELD-DECIMALS    = IT_DD03L-DECIMALS.
       TABLEFIELD-REF_TABLE   = IT_DD03L-REFTABLE.
       TABLEFIELD-REF_FIELD   = IT_DD03L-REFFIELD.

APPEND TABLEFIELD.
CLEAR TABLEFIELD.
ENDLOOP.

Note:- this is a test code so ignore performance issues...

Please help me with some code ...to avoid the Runtime erorr.

Thanks,

jeevan.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Jeevan,

Why are moving only few fields from DD03L table to your field catalog? Why don't you use move-corresponding? The following code works for me in ECC6.0.

data: it_dd03l type table of dd03l initial size 0,

ls_dd03l type dd03l,

lt_fldcat TYPE lvc_t_fcat,

ls_fldcat TYPE lvc_s_fcat,

ls_where(72) TYPE c,

lt_where LIKE TABLE OF ls_where,

lt_fld LIKE TABLE OF ls_where,

lt_data_dy TYPE REF TO data.

field-symbols: <ft_data> TYPE STANDARD TABLE.

select * into table it_dd03l from dd03l

where tabname = 'VBAK'

and ( fieldname = 'VBELN' or fieldname = 'NETWR' ).

check sy-subrc eq 0.

loop at it_dd03l into ls_dd03l.

move-corresponding ls_dd03l to ls_fldcat.

append ls_fldcat to lt_fldcat.

move ls_dd03l-fieldname to ls_where.

append ls_where to lt_fld.

if ls_dd03l-fieldname = 'VBELN'.

clear ls_where.

concatenate ls_dd03l-fieldname ' <> ''''' into ls_where.

append ls_where to lt_where.

endif.

endloop.

check not lt_fldcat is initial.

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = lt_fldcat

IMPORTING

ep_table = lt_data_dy

EXCEPTIONS

generate_subpool_dir_full = 1

OTHERS = 2.

IF sy-subrc <> 0.

RAISE no_configuration_data.

ENDIF.

ASSIGN lt_data_dy->* TO <ft_data>.

check sy-subrc eq 0.

select (lt_fld) from VBAK into corresponding fields of table

<ft_data>

where (lt_where).

Thanks

Bala

15 REPLIES 15

former_member1052991
Active Participant
0 Kudos

hi jeevan,

LOOP AT IT_DD03L..
  IF IT_DD03L-DATATYPE = 'CURR'.
       TABLEFIELD-CFIELDNAME = IT_DD03L-FIELDNAME .
       ENDIF.
 
   IF IT_FIELDCAT3-DATATYPE = 'QUAN'.
       TABLEFIELD-QFIELDNAME = IT_DD03L-FIELDNAME .
  ENDIF.
       TABLEFIELD-TABNAME     = IT_DD03L-TABNAME.
       TABLEFIELD-FIELDNAME   = IT_DD03L-FIELDNAME.
       TABLEFIELD-DATATYPE    = IT_DD03L-DATATYPE.
       TABLEFIELD-INTLEN      = IT_DD03L-LENG.
       TABLEFIELD-INTTYPE     = IT_DD03L-INTTYPE .
       TABLEFIELD-ROLLNAME    = IT_DD03L-ROLLNAME.
       TABLEFIELD-DECIMALS    = IT_DD03L-DECIMALS.
       TABLEFIELD-REF_TABLE   = IT_DD03L-REFTABLE.
       TABLEFIELD-REF_FIELD   = IT_DD03L-REFFIELD.
 
APPEND TABLEFIELD.
CLEAR TABLEFIELD.
ENDLOOP.

I know for INTLEN we need to give the LENG value from DD03L, but for currency and quantity fields, did you tried with INTLENG values. I am not sure, it will work but try with that one.

Thanks,

Guna

0 Kudos

Hai Guna,

Thanks for the reply, I tried with that but no results......

thanks,

jeevan.

anup_deshmukh4
Active Contributor
0 Kudos

hello jeevan kumar ,

In your field Catlogue table Please try passing the below two fields

CFIELDNAME LVC_CFNAME CHAR 30 0 ALV control: Field name for currency unit referenced

QFIELDNAME LVC_QFNAME CHAR 30 0 ALV control: Field name for unit of measure referenced pass eg. MEINS for menge

it is necessery for the quantity and the amount filed ...!

you can also check the table MSEG for field MENGE ( IN TAB CURRENCY QUANTITY FIELDS ...) SAME IS FOR AMOUNT

This will surely work ,

Hope it helps,

Edited by: Anup Deshmukh on Jul 20, 2010 11:33 AM

Edited by: Anup Deshmukh on Jul 20, 2010 11:36 AM

0 Kudos

Hai Anup,

I tried passing the CFIELDNAME AND QFIELDNAME as REFFIELD from DD03L values...

But still it goes to short Dump with the same error..

Jeevan.

0 Kudos

Hi jeevan,

I verify the bülent. Your problem is referance fields , if you are dont give the referance fields information the itab fields, field symbol is dont understand assignment, field size default assign char1 size.

You must try give to referance field to your dynamic itab fields.

I hope it help you

Regards

İrfan.

0 Kudos

Hi jeevan,

I verify the bülent. Your problem is referance fields , if you are dont give the referance fields information the itab fields, field symbol is dont understand assignment, field size default assign char1 size.

You must try give to referance field to your dynamic itab fields.

I hope it help you

Regards

İrfan.

0 Kudos

Hai, Irfan,

Yes , I understand.....Pls see in the code I have assigned the

Ref_field = it_dd03l-Reffield

Ref_Table = it_dd03l-reftable.

that is the worry even after that it is not executing....

And now even u started giveing the DOMAIN name .

Still its throwing the same error.

Jeevan...

0 Kudos

Hi Thats interesting ,

but I think you must try nearly alternatives, so you can try give the static values to code,

Sample for (QUAN) fields

Ref_field = 'MEINS'

Ref_Table = 'MARA'.

Maybe referance is DBTAB required.

regards

0 Kudos

Ok Irfan.....I will try that .....Pls be here tomarrow......I may get late today..

thanks for your time

jeevan..

0 Kudos

Hai,

I even tried with a static code like........

it_output2-CFIELDNAME = 'WAERK' .

it_output2-CURRENCY = 'CUKY'.

it_output2-TABNAME = 'VBAP'.

it_output2-FIELDNAME = 'NETWR'.

it_output2-DATATYPE = 'CURR'.

it_output2-INTLEN = '000015'.

it_output2-INTTYPE = 'C' .

it_output2-ROLLNAME = 'NETWR_AP'.

it_output2-DECIMALS = '000002'.

it_output2-REF_TABLE = 'VBAP'.

it_output2-REF_FIELD = 'WAERK'.

it_output2-DOMNAME = 'WERTV8'.

APPEND IT_OUTPUT2.

and also tried increasing the INTLEN to 20 ....but the error is same...

Any Ideas............

Jeevan.

0 Kudos

Hi Jeevan

In fieldcatalog you set,

it_output2-TABNAME = 'VBAP'.

it_output2-FIELDNAME = 'NETWR'.

it_output2-REF_TABLE = 'VBAP'.

it_output2-REF_FIELD = 'WAERK'.

You have a misunderstanding here

NETWR is amount field and WAERK is currency UNIT field

in fieldcatalog REF_TABLE / REF_FIELD stands for database table and field for only type reference

do not confuse it with the reference table field in the database table fields,

Can u try with

it_output2-REF_TABLE = 'VBAP'.

it_output2-REF_FIELD = NETWR'.

or

it_output2-REF_TABLE = 'SLS_PAD25'. <-- field SLS_PAD25-KKOST is currency and length 16 field

it_output2-REF_FIELD = 'KKOST'.

if your problem can't be solved I 'll ask you for some screenshots from the debugger.

0 Kudos

Hai, Bulent and Bala,

Thanks a lot for your efforts.I tried both of your hints and it works fine now.

But now my doubt is...in the Bala's solution the table doesnt set ref_table name and ref_field names.And still it works .

Anyways...Bulent ur solution too works...

Thanks closing this thread...

jeevan.

0 Kudos

Once it works, it always works Jeevan

Good luck.

bbalci
Contributor
0 Kudos

Hello Jeevan

It has to be a field type mistake in your code,

most likely the length of target fields in your dynamic internal table

are not enough for source fields coming from database.

Than i recommend you to use a bigger quantitiy fields like QUAN 17 etc.

Just create a data element in se11 which uses domain QUAN17 and put it in a Z structure and than

set REFTABLE and REFFIELD fields of your fieldcatalog to this structure and field.

Seperately,

VBAK-NETWR is a currency field and MSEG-MENGE is a quantitiy field. They are not the same

you should create a data element for VBAK-NETWR with length CURR 17 too

and use them seperately in your dynamic tables accoding to your code.

I hope it helps.

Bulent

Former Member
0 Kudos

Hi Jeevan,

Why are moving only few fields from DD03L table to your field catalog? Why don't you use move-corresponding? The following code works for me in ECC6.0.

data: it_dd03l type table of dd03l initial size 0,

ls_dd03l type dd03l,

lt_fldcat TYPE lvc_t_fcat,

ls_fldcat TYPE lvc_s_fcat,

ls_where(72) TYPE c,

lt_where LIKE TABLE OF ls_where,

lt_fld LIKE TABLE OF ls_where,

lt_data_dy TYPE REF TO data.

field-symbols: <ft_data> TYPE STANDARD TABLE.

select * into table it_dd03l from dd03l

where tabname = 'VBAK'

and ( fieldname = 'VBELN' or fieldname = 'NETWR' ).

check sy-subrc eq 0.

loop at it_dd03l into ls_dd03l.

move-corresponding ls_dd03l to ls_fldcat.

append ls_fldcat to lt_fldcat.

move ls_dd03l-fieldname to ls_where.

append ls_where to lt_fld.

if ls_dd03l-fieldname = 'VBELN'.

clear ls_where.

concatenate ls_dd03l-fieldname ' <> ''''' into ls_where.

append ls_where to lt_where.

endif.

endloop.

check not lt_fldcat is initial.

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = lt_fldcat

IMPORTING

ep_table = lt_data_dy

EXCEPTIONS

generate_subpool_dir_full = 1

OTHERS = 2.

IF sy-subrc <> 0.

RAISE no_configuration_data.

ENDIF.

ASSIGN lt_data_dy->* TO <ft_data>.

check sy-subrc eq 0.

select (lt_fld) from VBAK into corresponding fields of table

<ft_data>

where (lt_where).

Thanks

Bala