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

cl_alv_table_create=>create_dynamic_table

Former Member
0 Likes
1,179

Hi,

When I use this method it is dumping

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = it_fieldcat

IMPORTING

ep_table = <new_table>.

The error What I am getting is "LOAD_PROGRAM_NOT_FOUND" "CX_SY_PROGRAM_NOT_FOUND" MESSAGE IS ' Program " " Not Found '.

Please help us in this issue

Thanks & Regards,

Sivaram Kandula

13 REPLIES 13
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,144

Can you please post the entire code of your program.

Also, what release are you on?

Regards,

Rich Heilman

Read only

0 Likes
1,144

Dear Rich,

I am facing very similar problem to the solution you gave here, but I couldn't get through with this, Hope you can certainly help me and I am pasting my code here: pls look into it.

Awards will be rewarded for sure...

  • Material Field properties are set here

WA_FIELDCAT-FIELDNAME = 'MATNR'.

WA_FIELDCAT-SELTEXT = TEXT-018.

WA_FIELDCAT-INTTYPE = 'C'.

WA_FIELDCAT-INTLEN = 18.

WA_FIELDCAT-OUTPUTLEN = 18.

APPEND WA_FIELDCAT TO T_FIELDCAT.

CLEAR WA_FIELDCAT.

  • Material Desc properties are set here

WA_FIELDCAT-FIELDNAME = 'MAKTX'.

WA_FIELDCAT-SELTEXT = TEXT-019.

WA_FIELDCAT-INTTYPE = 'C'.

WA_FIELDCAT-INTLEN = 35.

WA_FIELDCAT-OUTPUTLEN = 35.

WA_FIELDCAT-JUST = 'X'.

APPEND WA_FIELDCAT TO T_FIELDCAT.

CLEAR WA_FIELDCAT.

*added by sarath Dt:03.08.06,Ticket#483.

IF P_BATCH = 'X' OR P_FREEST = 'X'.

WA_FIELDCAT-FIELDNAME = 'CAT_DESC'.

WA_FIELDCAT-SELTEXT = TEXT-041.

WA_FIELDCAT-INTTYPE = 'C'.

WA_FIELDCAT-INTLEN = 35.

WA_FIELDCAT-OUTPUTLEN = 35.

WA_FIELDCAT-JUST = 'X'.

APPEND WA_FIELDCAT TO T_FIELDCAT.

CLEAR WA_FIELDCAT.

ENDIF.

*end of additoin by sarath Dt:03.08.06,Ticket#483.

  • Plant properties are set here

WA_FIELDCAT-FIELDNAME = 'WERKS'.

WA_FIELDCAT-SELTEXT = TEXT-020.

WA_FIELDCAT-INTTYPE = 'C'.

WA_FIELDCAT-INTLEN = 4.

WA_FIELDCAT-OUTPUTLEN = 4.

APPEND WA_FIELDCAT TO T_FIELDCAT.

CLEAR WA_FIELDCAT.

  • Plant properties are set here

*added by sarath Dt:03.08.06,Ticket#483.

IF P_BATCH = 'X' OR P_FREEST = 'X'.

WA_FIELDCAT-FIELDNAME = 'SPART'.

WA_FIELDCAT-SELTEXT = TEXT-042.

WA_FIELDCAT-INTTYPE = 'C'.

WA_FIELDCAT-INTLEN = 35.

WA_FIELDCAT-OUTPUTLEN = 35.

WA_FIELDCAT-JUST = 'X'.

APPEND WA_FIELDCAT TO T_FIELDCAT.

CLEAR WA_FIELDCAT.

ENDIF.

*end of additoin by sarath Dt:03.08.06,Ticket#483.

WA_FIELDCAT-FIELDNAME = 'MVGR1'.

WA_FIELDCAT-SELTEXT = TEXT-026.

WA_FIELDCAT-INTTYPE = 'C'.

WA_FIELDCAT-INTLEN = 9.

WA_FIELDCAT-OUTPUTLEN = 9.

APPEND WA_FIELDCAT TO T_FIELDCAT.

CLEAR WA_FIELDCAT.

  • Storage Location properties are set here

IF P_STOR = 'X'.

WA_FIELDCAT-FIELDNAME = 'LGORT'.

WA_FIELDCAT-SELTEXT = TEXT-021.

WA_FIELDCAT-INTTYPE = 'C'.

WA_FIELDCAT-INTLEN = 4.

WA_FIELDCAT-OUTPUTLEN = 4.

APPEND WA_FIELDCAT TO T_FIELDCAT.

CLEAR WA_FIELDCAT.

  • Stock Type properties are set here

WA_FIELDCAT-FIELDNAME = 'STOCKTYP'.

WA_FIELDCAT-SELTEXT = TEXT-022.

WA_FIELDCAT-INTTYPE = 'C'.

WA_FIELDCAT-INTLEN = 15.

WA_FIELDCAT-OUTPUTLEN = 15.

APPEND WA_FIELDCAT TO T_FIELDCAT.

CLEAR WA_FIELDCAT.

ENDIF.

    • added by gopal for ticket#536

  • This is for sorting the numeric fields only

DATA: IDX TYPE SY-TABIX,

D_IND TYPE SY-TABIX.

LOOP AT T_SIZES INTO T1 WHERE SIZE CO TEXT-043.

IDX = SY-TABIX.

IF T1-SIZE < 10.

CONCATENATE '0' T1-SIZE INTO T1-SIZE.

ELSEIF T1-SIZE = '9.5'.

CONCATENATE '0' T1-SIZE INTO T1-SIZE.

ENDIF.

APPEND T1.

CLEAR T1.

DELETE T_SIZES INDEX IDX .

CLEAR : IDX.

ENDLOOP.

CLEAR : IDX.

LOOP AT T_SIZES INTO T2 WHERE SIZE CO TEXT-044.

IDX = SY-TABIX.

APPEND T2.

CLEAR T2.

DELETE T_SIZES INDEX IDX .

CLEAR : IDX.

ENDLOOP.

SORT T2 BY SIZE .

APPEND LINES OF T2[] TO T1[].

SORT T1 BY SIZE .

IF T_SIZES[] IS INITIAL.

T_SIZES[] = T1[].

ELSE.

APPEND LINES OF T_SIZES[] TO T1[].

DESCRIBE TABLE T1[].

D_IND = SY-TABIX.

DELETE T_SIZES[] FROM 1 TO D_IND.

T_SIZES[] = T1[].

ENDIF.

**end of addition by gopal for ticket#536

LOOP AT T_SIZES INTO WA_SIZES.

IF WA_SIZES-SIZE CA '.'.

    • DEIK905030 for Ticket#691 by harsha on 31052007

  • REPLACE '.' WITH '_' INTO WA_SIZES-SIZE .

**End of changes for DEIK905030.

ENDIF.

  • Sizes of the material field properties are set here

WA_FIELDCAT-FIELDNAME = WA_SIZES-SIZE.

WA_FIELDCAT-SELTEXT = WA_SIZES-SIZE.

WA_FIELDCAT-INTTYPE = 'I'.

WA_FIELDCAT-INTLEN = 11.

WA_FIELDCAT-DO_SUM = 'X'.

WA_FIELDCAT-OUTPUTLEN = 11.

WA_FIELDCAT-NO_ZERO = 'X'.

APPEND WA_FIELDCAT TO T_FIELDCAT.

CLEAR WA_FIELDCAT.

ENDLOOP.

  • Total Field properties are set here

WA_FIELDCAT-FIELDNAME = 'TOTAL'.

WA_FIELDCAT-SELTEXT = TEXT-023.

WA_FIELDCAT-INTTYPE = 'I'.

WA_FIELDCAT-INTLEN = 13.

WA_FIELDCAT-OUTPUTLEN = 13.

WA_FIELDCAT-DO_SUM = 'X'.

APPEND WA_FIELDCAT TO T_FIELDCAT.

CLEAR WA_FIELDCAT.

  • maximum Retail Price field properties are set here

WA_FIELDCAT-FIELDNAME = 'MRPRT'.

WA_FIELDCAT-SELTEXT = TEXT-028.

WA_FIELDCAT-INTTYPE = 'C'.

WA_FIELDCAT-DECIMALS = 2.

WA_FIELDCAT-INTLEN = 13.

  • WA_FIELDCAT-OUTPUTLEN = 13.

APPEND WA_FIELDCAT TO T_FIELDCAT.

CLEAR WA_FIELDCAT.

  • maximum Retail Price field properties are set here

WA_FIELDCAT-FIELDNAME = 'MRP'.

WA_FIELDCAT-SELTEXT = TEXT-024.

WA_FIELDCAT-DO_SUM = 'X'.

WA_FIELDCAT-INTTYPE = 'C'.

WA_FIELDCAT-DECIMALS = 2.

WA_FIELDCAT-INTLEN = 13.

  • WA_FIELDCAT-OUTPUTLEN = 13.

APPEND WA_FIELDCAT TO T_FIELDCAT.

CLEAR WA_FIELDCAT.

  • Moving Average Value properties are set here

WA_FIELDCAT-FIELDNAME = 'MAV'.

WA_FIELDCAT-SELTEXT = TEXT-025.

WA_FIELDCAT-DO_SUM = 'X'.

WA_FIELDCAT-INTTYPE = 'C'.

WA_FIELDCAT-DECIMALS = 2.

WA_FIELDCAT-INTLEN = 13.

  • WA_FIELDCAT-OUTPUTLEN = 13.

APPEND WA_FIELDCAT TO T_FIELDCAT.

CLEAR WA_FIELDCAT.

  • To create the dynamic Internal Table.

  • The fields of this table are obtained at runtime

CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE

EXPORTING

IT_FIELDCATALOG = T_FIELDCAT

IMPORTING

EP_TABLE = T_DATA

EXCEPTIONS

GENERATE_SUBPOOL_DIR_FULL = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

MESSAGE E074 WITH TEXT-015. " Error Creating int table.

EXIT.

ENDIF.

ASSIGN T_DATA->* TO <FS_BATCH>.

CREATE DATA WA_NEWTAB LIKE LINE OF <FS_BATCH>.

Read only

Former Member
0 Likes
1,144

Hi,

its no longer necessary to use this method if you have a basis release >= 6.40. Use cl_abap_typedescr and its subclasses. There you will find cl_abap_structdescr=>create( ). Thus you can create a data structure during runtime. The same is of course true for cl_abap_tabledescr.

Best regards,

Thomas

Read only

Former Member
0 Likes
1,144

Hi Rich,

My code is as follows, n contains the value of the date range, suppose if i give 06/2006 to 08/2006 then n contains value "3".

is_fieldcat-fieldname = 'BEZEI'.

is_fieldcat-ref_field = 'BEZEI'.

is_fieldcat-ref_table = 'S858'.

is_fieldcat-scrtext_l = 'CSR'.

is_fieldcat-scrtext_m = 'CSR'.

is_fieldcat-scrtext_s = 'CSR'.

APPEND is_fieldcat TO it_fieldcat.

DO n TIMES.

is_fieldcat-fieldname = 'SPBUP'.

is_fieldcat-ref_field = 'SPBUP'.

is_fieldcat-ref_table = 'S858'.

is_fieldcat-scrtext_l = date.

is_fieldcat-scrtext_m = date.

is_fieldcat-scrtext_s = date.

APPEND is_fieldcat TO it_fieldcat.

IF date+4(2) = 12.

date3(1) = date3(1) + 1.

date+4(2) = '00'.

ENDIF.

date4(2) = date4(2) + i.

date14(1) = date4(1).

IF date+5(1) = ' '.

date+4(1) = 0.

date5(1) = date14(1).

ENDIF.

ENDDO.

is_fieldcat-fieldname = 'TOTALS'.

is_fieldcat-ref_field = 'UMNETWR'.

is_fieldcat-ref_table = 'S858'.

is_fieldcat-scrtext_l = 'TOTALS'.

is_fieldcat-scrtext_m = 'TOTALS'.

is_fieldcat-scrtext_s = 'TOTALS'.

APPEND is_fieldcat TO it_fieldcat.

FIELD-SYMBOLS : <new_table> TYPE REF TO data.

DATA : lt_data TYPE REF TO data.

ASSIGN lt_data TO <new_table>.

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = it_fieldcat

IMPORTING

ep_table = <new_table>.

The dump is getting in this method only.

Please clarify me, if I am wrong.

Thanks & Regards,

Sivaram Kandula

Read only

Former Member
0 Likes
1,144

Hi Rich,

I am using SAP R/3 Enterprise version.

Regards,

Sivaram Kandula

Read only

Former Member
0 Likes
1,144

O.k. with

FIELD-SYMBOLS : <new_table> TYPE REF TO data.

it cannot work. You have to specify at least

FIELD-SYMBOLS : <new_table> TYPE any table!

Regards,

Thomas

Read only

Former Member
0 Likes
1,144

To be more precise: Try

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = it_fieldcat

IMPORTING

ep_table = lt_data.

assign lt_data->* to <fs_tab>.

Here <fs_tab> should be a field symbol of type any table.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,144

Sivaram, I noticed that you created this thread as well as another with another user(Shankar Reddy), I assume that this is your colleague. Will you be awarding points for helpful answers and marking as solved under his ID. You will not be able to do so under your newly created ID as you are not the owner of the treads.

Regards,

Rich Heilman

Read only

0 Likes
1,144

Please check this program, I have made some changes and commented things out.



report zrich_0003.

<b>field-symbols: <dyn_table> type standard table,
               <dyn_wa>.

data: new_table type ref to data,
      new_line  type ref to data,
      is_fieldcat type lvc_s_fcat,
      it_fieldcat type lvc_t_fcat..

data: i type i.
data: date1 type sy-datum.

parameters: P_SPBUP type SPBUP.
parameters: n type i.</b>
is_fieldcat-fieldname = 'BEZEI'.
<b>*is_fieldcat-ref_field = 'BEZEI'.
*is_fieldcat-ref_table = 'S858'.</b>
is_fieldcat-scrtext_l = 'CSR'.
is_fieldcat-scrtext_m = 'CSR'.
is_fieldcat-scrtext_s = 'CSR'.

append is_fieldcat to it_fieldcat.

do n times.
  is_fieldcat-fieldname = p_SPBUP.
<b>*  is_fieldcat-ref_field = 'SPBUP'.
*  is_fieldcat-ref_table = 'S858'.</b>
  is_fieldcat-scrtext_l = p_SPBUP.
  is_fieldcat-scrtext_m = p_SPBUP.
  is_fieldcat-scrtext_s = p_SPBUP.
  append is_fieldcat to it_fieldcat.

<b>  p_SPBUP+4(2) = p_SPBUP+4(2) + 1.
  if p_SPBUP+4(2) = 13.
    p_SPBUP+0(4) = p_SPBUP+0(4) + 1.
    p_SPBUP+4(2) = '01'.
  endif.

*  if date+4(2) = 12.
*    date+3(1) = date+3(1) + 1.
*    date+4(2) = '00'.
*  endif.
*  date+4(2) = date+4(2) + i.
*  date1+4(1) = date+4(1).
*  if date+5(1) = ' '.
*    date+4(1) = 0.
*    date+5(1) = date1+4(1).
*  endif.</b>
enddo.

is_fieldcat-fieldname = 'TOTALS'.
<b>*is_fieldcat-ref_field = 'UMNETWR'.
*is_fieldcat-ref_table = 'S858'.</b>
is_fieldcat-scrtext_l = 'TOTALS'.
is_fieldcat-scrtext_m = 'TOTALS'.
is_fieldcat-scrtext_s = 'TOTALS'.
append is_fieldcat to it_fieldcat.

<b>*FIELD-SYMBOLS : <new_table> TYPE REF TO data.
*DATA : lt_data TYPE REF TO data.
*ASSIGN lt_data TO <new_table>.</b>
call method cl_alv_table_create=>create_dynamic_table
        exporting
              it_fieldcatalog = it_fieldcat
        importing
              ep_table = <b>new_table.</b>

<b>
assign new_table->* to <dyn_table>.

* Create dynamic work area and assign to FS
create data new_line like line of <dyn_table>.
assign new_line->* to <dyn_wa>.</b>




Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,144

Hi Rich,

thank you very much with your valuable inputs,this really helps me to sort out the problem, but still I am facing some issues.

Rich, you are right for the first time I have used my colleague user id only. Later I have created my own Id. Sorry for the inconvinience.

I got the structure to <dyn_table>, now I have to populate the data to it.

Example, presently my program is getting the Internal table data Like this....

if i give date range 06/2005 07/2005 my table contains

<b>BEZEI BZTXT SPBUP totals</b>

Shiva Newyork 200506 0.00

shiva Newyork 200507 140.00

shankar New Jersy 200506 40.00

shankar New Jersy 200507 80.00

but in the ALV Output we should display lik this

<b>BEZEI BZTXT 06/2005 07/2005 totals</b>

Shiva New york 0.00 140.00 140.00

shankar New Jersy 40.00 80.00 120.00

Now I am able to display the ALV like this and dynamically generated the Internal table structure with the Date range Fields (As per your suggestion) <dyn_table>. Now My question is how to populate the data as above. Please help me in this issue.

Thanks in advance.

Regards,

Sivaram Kandula

Read only

0 Likes
1,144

You must use the ASSIGN COMPONENT statement to assign the component to a field symbol, then fill the data, You must keep track of your dynamic column names, maybe in an internal table or something.

Please remember to award points for helpful answers and mark your posts as solved when solved completely. Thanks.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,144

Hi Rich,

Thanks for your reply, I have awarded the points for your solution.

First time I am using the Field Symbols can you please give me more elobarate answer with example. So that I will implement it to my program.

Regards,

Sivaram Kandula

Read only

0 Likes
1,144

Please check your other thread from yesterday. It gives an example program.

Regards,

Rich Heilman