‎2010 Mar 18 9:58 AM
Hi Experts,
i am working on Dynamic ALV.I have created a Dynamic Fieldcatalog,which is storing the correct field values as per requirement.
When I debbug the code: I get the following error when I am calling method 'create_dynamic_table'.
"Unable to interpret "MATERIALS(000010)". Possible 10 MATERIALS(000010)"
DATA: g_table TYPE REF TO data.CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = i_fieldcat
IMPORTING
ep_table = g_table.
* EXCEPTIONS
* generate_subpool_dir_full = 1
* OTHERS = 2.Please advice how do I approach this error.Is some change required in my piece of code?
Thanks.
‎2010 Mar 18 10:02 AM
It seems that something is wrong with you fieldcatalog. Can you share it with us?
Regards
Marcin
‎2010 Mar 18 10:02 AM
It seems that something is wrong with you fieldcatalog. Can you share it with us?
Regards
Marcin
‎2010 Mar 18 10:09 AM
HI Marcin Pciak,
Thanks for the prompt reply.Please advice what could be the possible error.I am checking as well.
IF i_fieldcat[] IS INITIAL.
lcount = lcount + 1.
w_fieldcat-fieldname = 'WERKS'.
w_fieldcat-seltext = text-004.
w_fieldcat-col_pos = lcount.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
lcount = lcount + 1.
w_fieldcat-fieldname = 'MATNR'.
w_fieldcat-seltext = text-005.
w_fieldcat-col_pos = lcount.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
lcount = lcount + 1.
w_fieldcat-fieldname = 'MAKTX'.
w_fieldcat-seltext = text-006.
w_fieldcat-col_pos = lcount.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
lcount = lcount + 1.
w_fieldcat-fieldname = 'MEINS'.
w_fieldcat-seltext = text-007.
w_fieldcat-col_pos = lcount.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
lcount = lcount + 1.
w_fieldcat-fieldname = 'POPER'.
w_fieldcat-seltext = text-008.
w_fieldcat-col_pos = lcount.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
lcount = lcount + 1.
w_fieldcat-fieldname = 'BDATJ'.
w_fieldcat-seltext = text-009.
w_fieldcat-col_pos = lcount.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
SORT i_tckh3 BY el_hv.
LOOP AT i_tckh3 INTO w_tckh3.
SORT i_tckh1 BY elemt.
LOOP AT i_tckh1 INTO w_tckh1 WHERE elemt = w_tckh3-elemt.
lcount = lcount + 1.
CONCATENATE w_tckh1-txele ' ' INTO w_fieldcat-seltext.
CONCATENATE w_tckh1-txele ' ' INTO w_fieldcat-coltext.
CONCATENATE w_tckh1-txele ' ' INTO w_fieldcat-fieldname.
* CONDENSE w_fieldcat-fieldname NO-GAPS.
w_fieldcat-col_pos = lcount.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
CLEAR: w_tckh1.
ENDLOOP.
CLEAR:w_tckh3.
ENDLOOP.
lcount = lcount + 1.
w_fieldcat-fieldname = 'TOTAL'.
w_fieldcat-seltext = text-010.
w_fieldcat-col_pos = lcount.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
ENDIF.
‎2010 Mar 18 10:15 AM
This looks suspiscious
SORT i_tckh3 BY el_hv.
LOOP AT i_tckh3 INTO w_tckh3.
SORT i_tckh1 BY elemt.
LOOP AT i_tckh1 INTO w_tckh1 WHERE elemt = w_tckh3-elemt.
lcount = lcount + 1.
CONCATENATE w_tckh1-txele ' ' INTO w_fieldcat-seltext.
CONCATENATE w_tckh1-txele ' ' INTO w_fieldcat-coltext.
CONCATENATE w_tckh1-txele ' ' INTO w_fieldcat-fieldname.
* CONDENSE w_fieldcat-fieldname NO-GAPS.
w_fieldcat-col_pos = lcount.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
CLEAR: w_tckh1.
ENDLOOP.
CLEAR:w_tckh3.
ENDLOOP.
Don't know excatly what you appending here to field catalog. One thing which I can catch
"try
WRITE w_tchkh1-txele TO ... LEFT-JUSTIFIED.
"instead of
CONCATENATE....
Anyhow I suggest to comment this part and rerun the program to ensure that this one is not causing the error. If not then investigate further.
Regards
Marcin
‎2010 Mar 18 10:22 AM
Hi Marcin,
I changed the code as per your suggestion,still the same error
please advice.I have cross checked a number of posts on SDN,but all follow the same sequence,so I think i have not missed out on any point.
Please suggest.
Thanks.
‎2010 Mar 18 10:29 AM
This works fine for me
DATA: i_fieldcat TYPE lvc_t_fcat,
w_fieldcat TYPE lvc_s_fcat.
DATA: lcount TYPE i,
g_table TYPE REF TO data.
lcount = lcount + 1.
w_fieldcat-fieldname = 'WERKS'.
w_fieldcat-seltext = text-004.
w_fieldcat-col_pos = lcount.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
lcount = lcount + 1.
w_fieldcat-fieldname = 'MATNR'.
w_fieldcat-seltext = text-005.
w_fieldcat-col_pos = lcount.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
lcount = lcount + 1.
w_fieldcat-fieldname = 'MAKTX'.
w_fieldcat-seltext = text-006.
w_fieldcat-col_pos = lcount.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
lcount = lcount + 1.
w_fieldcat-fieldname = 'MEINS'.
w_fieldcat-seltext = text-007.
w_fieldcat-col_pos = lcount.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
lcount = lcount + 1.
w_fieldcat-fieldname = 'POPER'.
w_fieldcat-seltext = text-008.
w_fieldcat-col_pos = lcount.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
lcount = lcount + 1.
w_fieldcat-fieldname = 'BDATJ'.
w_fieldcat-seltext = text-009.
w_fieldcat-col_pos = lcount.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
lcount = lcount + 1.
w_fieldcat-fieldname = 'TOTAL'.
w_fieldcat-seltext = text-010.
w_fieldcat-col_pos = lcount.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = i_fieldcat
IMPORTING
ep_table = g_table
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
Check it once again, if possible in some new program
Regards
Marcin
‎2010 Mar 18 10:48 AM
‎2010 Mar 19 8:05 AM
Can you please paste here example values you have in the tables i_tckh3 and i_tckh1. I think this is crucial here.
You can print the ouput of this tables with WRITE statement and then just copy/paste it here, so I we can see couple rows of example data.
‎2010 Mar 19 8:22 AM
Hi Marcin,
Thanks for all the help,finally solved the issue.I made a small error while coding the Fieldcatalog:
now the changed code looks like the following code:
LOOP AT i_tckh3 INTO w_tckh3.
LOOP AT i_tckh1 INTO w_tckh1 WHERE elemt = w_tckh3-elemt.
lcount = lcount + 1.
WRITE w_tckh1-txele TO w_fieldcat-seltext LEFT-JUSTIFIED.
CONCATENATE 'KST' w_tckh3-el_hv INTO w_fieldcat-fieldname.
TRANSLATE w_fieldcat-fieldname TO UPPER CASE.
w_fieldcat-col_pos = lcount.
w_fieldcat-ref_field = 'KST001'.
w_fieldcat-ref_table = 'KEPH'.
w_fieldcat-datatype = 'CURR'.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
CLEAR: w_tckh1.
ENDLOOP.
CLEAR:w_tckh3.
ENDLOOP.Emphasis on the COncatenate statement in the loop.Earlier I was passing the TXELE field to fieldname,which was wrong.
Thanks a Ton!!!!
I have a small dount in the next step:While assigning the values to the final internal table:
LOOP AT i_final INTO w_final.
ASSIGN COMPONENT 'WERKS' OF STRUCTURE <i_value> TO <fs1>.
<fs1> = w_final-werks.
ASSIGN COMPONENT 'MATNR' OF STRUCTURE <i_value> to <fs1>.
<fs1> = w_final-matnr.
LOOP AT i_keph INTO w_keph WHERE kalnr = w_final-kalnr.
ASSIGN COMPONENT 'KST001' OF STRUCTURE <i_value> TO <fs1>.
<fs1> = <FS1> + w_keph-kst001.
ENDLOOP.
APPEND <i_value> TO <i_table>.
CLEAR: <i_value>.
ENDLOOP.Now the LOOP AT I_KEPH: has all the values of the cost fields.I need to assign the appropriate value of KSTXXX to the corresponding Dynamic fieldcatalog:What should the procedure be.I am NOT able to check what values are there in dynamic calatog.
Hope this point is not too confusing.
‎2010 Mar 19 8:38 AM
If I understand correctly your are asking about this part
LOOP AT i_keph INTO w_keph WHERE kalnr = w_final-kalnr.
ASSIGN COMPONENT 'KST001' OF STRUCTURE <i_value> TO <fs1>. "here you want to address KSTXXX components one by one?
<fs1> = <FS1> + w_keph-kst001.
ENDLOOP.
If so you can follow this logic
data: field(6) type c value 'KST',
number(3) type n.
Loop...
do 10 times. "depending on number of KSTXXX fields in the structure
number = sy-index. "will hold 001, 002, 003
concatenate field number into field. 'KST001, KST002....
ASSIGN COMPONENT (field) of structure <i_vale> to <fs1>.
if sy-subrc = 0.
<fs1> = <FS1> + w_keph-kst001.
else.
exit.
endif.
enddo.
endloop.
Here, for each row you go through the strcutre and assign KST001, KST002 and so on and finally you add all the values to <fs1>.
Regards
Marcin
‎2010 Mar 19 9:09 AM
Hi Marcin,
Yes thats exactly what I was looking for.Its a good option that you have suggested,but have a look at the following code:
*dynamic field value
LOOP AT i_keph INTO w_keph WHERE kalnr = w_final-kalnr. "W_KEPH has just one line item
ASSIGN COMPONENT 'KST001' OF STRUCTURE <i_value> TO <fs1>.
<fs1> = <fs1> + w_keph-kst001. "how to dynamically assign a field of w_keph?
ASSIGN COMPONENT 'KST002' OF STRUCTURE <i_value> TO <fs1>.
<fs1> = <fs1> + w_keph-kst002.
ASSIGN COMPONENT 'KST003' OF STRUCTURE <i_value> TO <fs1>.
<fs1> = <fs1> + w_keph-kst003.
ENDLOOP.Now KSTXX have values from KST001-KST040,do I need to assign each field manually from W_KEPH?
‎2010 Mar 19 9:19 AM
Hi Marcin,
Even after changing the code as per your suggestion,I have a doubt:
LOOP AT i_keph INTO w_keph.
DO l_line TIMES. "depending on number of KSTXXX fields in the structure
l_number = sy-index. "will hold 001, 002, 003
CONCATENATE l_field l_number INTO l_field. "'KST001, KST002....
ASSIGN COMPONENT l_field OF STRUCTURE <i_value> TO <fs1>.
IF sy-subrc = 0.
<fs1> = <fs1> + w_keph-kst001. "W_KEPH-KST001 is still fixed,but this needs to be assigned dynamically.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDLOOP.
‎2010 Mar 19 9:20 AM
Same way:
data: field(6) type c value 'KST',
str_field(13) type c value 'W_KEPH-KST'. "you just say that you will be addressing component of structure
...
Loop...
do 40 times.
number = sy-index.
concatenate field number into field.
ASSIGN COMPONENT (field) of structure <i_vale> to <fs1>. "KST001 .... of structure <i_value>
ASSIGN (str_field) to <fs2>. "KSTXXX of structure W_KEPH
if sy-subrc = 0.
<fs1> = <FS1> + <fs2>. "now add
else.
exit.
endif.
enddo.
endloop.
‎2010 Mar 19 9:23 AM
‎2010 Mar 19 9:37 AM
Hi Marcin,
Thanks for all the inputs.You have been of great help.
Thanks a Ton!!!!
Closing the thread.
‎2010 Mar 19 9:41 AM
Hi Marcin,
When I am assigning points I am getting the following error on SDN:
"An error has occured while assigning points. Please refresh the thread view and try again. "Now?
‎2010 Mar 19 9:44 AM
I think something has happend to "Pointing system" . I also got cleared points on my account. You can come back later and try giving points once it is fixed. Thanks in advance.
‎2010 Mar 19 10:46 AM
‎2010 Mar 19 10:59 AM
Hi Marcin,
There is a Total field at the end of the ALV,we need to add values rowwise,only of the final dynamic KSTXXX fields.
How do I approach this.I tried looking for options with Loop at I_KEPH into W_KEPH.
But the following code will add all the columns rowwise for I_KEPH,BUT I want it should only total the fields in I_FIELDCAT.
*Total Cost
LOOP AT i_keph INTO w_keph WHERE kalnr = w_final-kalnr.
DO 40 TIMES. "depending on number of KSTXXX fields in the structure
l_number = sy-index. "will hold 001, 002, 003
ASSIGN COMPONENT 'TOTAL' OF STRUCTURE <i_value> TO <fs1>.
CONCATENATE l_kstx l_number INTO l_str_field.
ASSIGN (l_str_field) TO <fs2>. "KSTXXX of structure W_KEPH
IF sy-subrc = 0.
<fs1> = <fs1> + <fs2>. "i only want to add those fields which are final in Fieldcatalog.
UNASSIGN <fs2>.
CLEAR: l_str_field.
ENDIF.
ENDDO.
APPEND <fs1> TO <i_table>.
ENDLOOP.Also When I Call Method for displaying the it_Final to the ALV GRID,it does NOT show the DYNAMIC FIELDS in Debug mode.
CALL METHOD set_table_for_first_display
CHANGING
it_outtab = i_final.Please suggest.
‎2010 Mar 19 11:31 AM
Can you please open new thread for this. This one is already mixed with all other issues you had. This will also encourage people to take their trial to anwser.
Also explain more what do you mean by this
But the following code will add all the columns rowwise for I_KEPH,BUT I want it should only total the fields in I_FIELDCAT.
With this code you will add only values for fields KSTXXX and which ones you really want to sum up.
‎2010 Mar 19 11:40 AM
Hi Marcin,
I tried another option after posting the query,and i think i have got any answer:
the following code will explain:
*Total Cost
LOOP AT i_keph INTO w_keph WHERE kalnr = w_final-kalnr.
DO 40 TIMES. "depending on number of KSTXXX fields in the structure
l_number = sy-index. "will hold 001, 002, 003
ASSIGN COMPONENT 'TOTAL' OF STRUCTURE <i_value> TO <fs1>.
CONCATENATE l_kstx l_number INTO l_str_field.
ASSIGN (l_str_field) TO <fs2>. "KSTXXX of structure W_KEPH
READ TABLE i_fieldcat INDEX l_index INTO w_fieldcat .
IF sy-subrc EQ 0.
CONCATENATE l_kstx1 w_fieldcat-fieldname INTO l_var.
IF l_var = l_str_field.
<fs1> = <fs1> + <fs2>.
UNASSIGN <fs2>.
CLEAR: l_str_field,l_var.
ENDIF.
l_index = l_index + 1.
ENDIF.
* IF sy-subrc = 0.
* ENDIF.
ENDDO.
ENDLOOP.Will keep you updated and If I happen to have a doubt in this,then I will open a new post.Thanks.
‎2010 Mar 18 11:18 AM
Check these OSS notes, maybe there is something which applies to your case.
[Note 454535 - ALV-TableCreate:generating length >80 char. for program line|https://websmp130.sap-ag.de/sap(bD1wbCZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=454535]
[Note 654306 - ALV grid: Field catalog entry intlen|https://websmp130.sap-ag.de/sap(bD1wbCZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=654306]
[Note 721628 - ALV: Dynamic table generation for decimal fields|https://websmp130.sap-ag.de/sap(bD1wbCZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=721628]
Regards
Marcin
‎2010 Mar 18 11:30 AM
When i commented the following code the error has gone:
* SORT i_tckh3 BY el_hv.
* LOOP AT i_tckh3 INTO w_tckh3.
* SORT i_tckh1 BY elemt.
* LOOP AT i_tckh1 INTO w_tckh1 WHERE elemt = w_tckh3-elemt.
* lcount = lcount + 1.
* WRITE w_tckh1-txele TO w_fieldcat-seltext LEFT-JUSTIFIED.
* WRITE w_tckh1-txele TO w_fieldcat-coltext LEFT-JUSTIFIED.
* WRITE w_tckh1-txele TO w_fieldcat-fieldname LEFT-JUSTIFIED.
* w_fieldcat-col_pos = lcount.
* APPEND w_fieldcat TO i_fieldcat.
* CLEAR w_fieldcat.
* CLEAR: w_tckh1.
* ENDLOOP.
* CLEAR:w_tckh3.
* ENDLOOP.any suggestions...
But the main purpose of this Fieldcatalog is for Dynamic fields.
Edited by: p317980 on Mar 18, 2010 12:31 PM
‎2010 Mar 18 11:35 AM
What you excatly store in these tables? Dynamic field names? If so please ensure that you are providing field names in CAPITALS and that you don't have duplicate entries after these two loops.
In debugger check also the content of the fieldcatalog.
Edited by: Marcin Pciak on Mar 18, 2010 12:35 PM
‎2010 Mar 18 11:36 AM
Hi Marcin,
When I check this code in debug mode:G_TABLE is blank.
* Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = i_fieldcat
IMPORTING
ep_table = g_table
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
ASSIGN g_table->* TO <i_table>.
* Create dynamic work area and assign to FS
CREATE DATA w_data LIKE LINE OF <i_table>.
ASSIGN w_data->* TO <i_value>.please advice.
‎2010 Mar 18 11:41 AM
Do you mean, there is no reference stored in G_TABLE? Or you mean that table <i_table> is empty?
G_TABLE musn't be blank if you are able to perform
ASSIGN g_table->* TO <i_table>.
It is the purpose of dynamic table creation to have empty table created but its structure is dynamic, meaning that based on fields provided in field catalog it will be generated.
‎2010 Mar 18 11:46 AM
Hi Marcin,
I changed the FIELDNAME to UPPER CASE AS BELOW:
LOOP AT i_tckh3 INTO w_tckh3.
LOOP AT i_tckh1 INTO w_tckh1 WHERE elemt = w_tckh3-elemt.
lcount = lcount + 1.
WRITE w_tckh1-txele TO w_fieldcat-seltext LEFT-JUSTIFIED.
WRITE w_tckh1-txele TO w_fieldcat-coltext LEFT-JUSTIFIED.
WRITE w_tckh1-txele TO w_fieldcat-fieldname LEFT-JUSTIFIED.
TRANSLATE w_fieldcat-fieldname TO UPPER CASE.
w_fieldcat-col_pos = lcount.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
CLEAR: w_tckh1.
ENDLOOP.
CLEAR:w_tckh3.
ENDLOOP.the fieldcatalog stores the headings as per number of records in the loop.The data is coming correct in i_fieldcat.
The error still persists.
‎2010 Mar 18 12:02 PM
‎2010 Mar 18 12:08 PM
Hi Marcin,
I viewed G_TABLE in debug mode:The following displays the results in debug mode.
G_TABLE->* Standard Table[0x7(140)]When I comment the loop in the fieldcatalog,then the error does not appear,But we have to define an Dynamic internal table,so we need to populate it through this procedure.
I have specified only the static fields in the internal table of the final ALV.
Do you suggest some other option of doing the same??
‎2010 Mar 18 12:14 PM
Are these dynamic fields available in the DDIC?
I can see that you didn't type your dynamic fields in any way. Try giving reference to DDIC fields
w_fieldcatalog-ref_field = "name of field to take the type from
w_fieldcatalog-ref_table = "name of table this field is placed in
You may try also providing data type directly by means of fields DATATYPE , INTTYPE , INTLEN .
It is really hard to tell what may cause the problem without seeing the content of these two misterious tables you have for dyncamic fields. Try adding just one field from these tables by looping only once, observe what is placed in the fieldcatalog and whether this is correct.
‎2010 Mar 18 4:35 PM
Hi Marcin,
Thanks for all the prompt replies,I will try these changes first thing tomorrow.Will keep you posted on this.Am hoping that the issue should get resolved...
Thanks once again!!!!
‎2010 Mar 19 4:57 AM
Hi Marcin,
I have added the Ref_Field & Ref_Table in the fieldcatalog.Now the error message has changed to :
"MATERIALS" is not expected 10 MATERIALS"please suggest what needs to be done.I am chekcing the code,the fields are getting updated in fieldcatalog.
Thanks.
‎2010 Mar 19 11:24 AM
‎2010 Mar 19 12:15 PM
Hi anonymous,
1 - it is not recommended to use METHOD cl_alv_table_create=>create_dynamic_table. This method uses GENERATE SUBROUTINE POOL internally and thus will do an implicit database commit. This is unwanted and possibly dangerous.
2 - you may use CL_SALV_TABLE (tons of blogs and demos available) because it will automatically create a field catalog internally. Automatically you have all available F1 F4 without any extra coding. CL_SALV is the only ALV that is rleased by SAP for customer use.
3 - If you do not dare to do so, you have two alternatives:
a) Call function 'LVC_FIELDCATALOG_MERGE' for all dictionary tables that have your fields, i.e. mara, makt, etc. In the field catalog returned delete all lines except the ones with your fields. Inspect the field catalog to know how it should be organized.
3) For dynamic table cretion, use RTTS Run time type services (class CL_ABAP_TYPEDESC and derived ones.
Regards,
Clemens
‎2010 Mar 22 6:12 AM
The question is answered.Error message while assigning the deserving answere.Please advice.