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

modify internal table embedded in internal table as field

Former Member
0 Likes
1,779

Hi Experts,

I am using function module CRM_DNO_READ_ORDER_TEXT.

One of the output table of this fm is ET_ALLTEXTS whixh is of structure COMT_TEXT_TEXTDATA_T.

This structure has two fields one is GUI and other is LINES which itself contains the table in it.

I want to delete one row from the data of this LINES table in main table ET_ALLTEXTS .

Actually, this LINES table contains the texts entered by user from some application. So i want to edit the text.

Pls help me..this is very complicated.

thnx

DIvya

11 REPLIES 11
Read only

Former Member
0 Likes
1,355

Hi Divya,

You need to create one local internal table of type LINES.

loop at ET_ALLTEXTS.

local_int_table = ET_ALLTEXTS-LINES.

refresh ET_ALLTEXTS-LINES.

now manipualte this local internal table and pass it back to ET_ALLTEXTS-LINES.

modify ET_ALLTEXTS here.

endloop.

hope this helps.

Regards,

Nilesh.

Read only

Former Member
0 Likes
1,355

I suppose you have a work area for ET_ALLTEXTS

Just put the line you want to modify in ET_ALLTEXTS in the work area.

After that, just treat the field LINES in the work area as a normal table.

You need to do something like this

read table ET_ALLTEXTS into w_ET_ALLTEXTS where gui = '1'.
if sy-subrc = 0.
delete w_ET_ALLTEXTS-lines where table_line <> space.
endif.

Read only

0 Likes
1,355

Hi Nilesh n Ramiro,

actually when I check the type of ET_ALLTEXTS it will show table type COMT_TEXT_TEXTDATA_T.

When i try to assign like int_local_table = ET_ALLTEXTS-LINES it gives error that " ET_ALLTEXTS is a table without a header line and therfore no component called LINES".

Thats the main problem. I have tried with field symbol as well but again some type mismatch is coming.

please help.

anyways thnx for ur repies.

Bye

Divya

Read only

0 Likes
1,355

Check this quick example. And stop using header lines. Declare the work areas yourself. It will save you a lot of problems with nested tables

TYPES: BEGIN OF uno,
a,
END OF uno.

TYPES: tty_uno TYPE STANDARD TABLE OF uno
          WITH NON-UNIQUE KEY table_line.

TYPES: BEGIN OF dos,
a,
lines TYPE tty_uno,
END OF dos.

DATA: itab TYPE TABLE OF dos,
      w_itab LIKE LINE OF itab,
      w_lines LIKE LINE OF w_itab-lines,
      l_tabix TYPE i.

w_lines-a = '1'.
APPEND w_lines TO w_itab-lines.
w_lines-a = '2'.
APPEND w_lines TO w_itab-lines.
w_itab-a = '1'.
APPEND w_itab TO itab.
w_itab-a = '2'.
APPEND w_itab TO itab.
READ TABLE itab INTO w_itab WITH KEY a = '1'.
IF sy-subrc = 0.
  l_tabix = sy-tabix.
  DELETE w_itab-lines WHERE a = '1'.
  MODIFY itab FROM w_itab INDEX l_tabix.
ENDIF.

Read only

0 Likes
1,355

Hi Divya,

the local internal table should refer to the data type for LINES and not ET_ALLTEXTS. You need to define the work area and main body of the internal table explicitly and then use int_local_table[] = ET_ALLTEXTS-LINES[]. You need to assign the body of the internal table explicitly.

Regards,

Nilesh.

Edited by: Nilesh Masurkar on Nov 5, 2009 5:17 PM

Edited by: Nilesh Masurkar on Nov 5, 2009 5:18 PM

Read only

0 Likes
1,355

Nilesh,

I did the same type what is require but it says that the ET_ALLTEXTS does not have LINES component.

its not the problem with the local inetrnal table. Thta i have made of type LINE only.

Actually ET_ALLTEXTS is of^'table type ' COMT_TEXT_TEXTDATA_T and this is of type COMT_TEXT_TEXTDATA.

Read only

0 Likes
1,355

Hi Divya,

Something wrong in your declaration. sorry, i can't check this on my system.

Regards,

nilesh.

Read only

0 Likes
1,355

I guess Nilesh is right, there is something wrong with your declaration. Me for one, I've tried to reproduce your problem and I don't see any problem here. How did you declare your internal table for example?

When you want to delete a line from table LINES you can't just say:


delete et_alltexts-lines index 1.

Because this will give you the error message with 'table without header line....". Instead you first have to loop at this ET_ALLTEXTS internal table and only then you have access to the individual lines, which is an internal table as well. The following is only an example, but it should be helpful:


DATA: gv_header_guid TYPE crmt_object_guid.
DATA: gt_textdata    TYPE comt_text_textdata_t ,
      gt_alltexts    TYPE comt_text_textdata_t.

FIELD-SYMBOLS: <alltext>     LIKE LINE OF gt_alltexts.

CALL FUNCTION 'CRM_DNO_READ_ORDER_TEXT'
  EXPORTING
    iv_header_guid = gv_header_guid
  IMPORTING
    et_textdata    = gt_textdata
    et_alltexts    = gt_alltexts.

LOOP AT gt_alltexts ASSIGNING <alltext>.

  DELETE <alltext>-lines INDEX 1.

ENDLOOP.

Read only

Former Member
0 Likes
1,355

Try using references..workarea is anyways not optimal way of accessing intenal tables and changing stuff:

Exampls:

Data: lr_text_textdat type ref to COMT_TEXT_TEXTDATA,

lr_text_line_t type ref to COMT_TEXT_LINES_T,

lr_text_line type ref to TLINE.

Loop or read <TABLE> reference into lr_test_testdata.

get reference of lr_test_testdata->LINES into lr_text_line_t.

loop or read lr_text_line_t reference into lr_text_line

now any changes on this reference...delete..update will directly happen on main parent table.

Hope this helps.

Regards,

Jemin

Read only

Former Member
0 Likes
1,355

Hi Divya,

Please check the below code.

DATA: li_alltext TYPE TABLE OF comt_text_textdata,

lw_alltext TYPE comt_text_textdata,

li_lines TYPE TABLE OF tline,

lw_lines TYPE tline.

LOOP AT li_alltext INTO lw_alltext.

REFRESH li_lines[].

li_lines[] = lw_alltext-lines[].

LOOP AT li_lines INTO lw_lines.

*/----


>>>>>Delete the text lines here

ENDLOOP.

REFRESH lw_alltext-lines[].

lw_alltext-lines[] = li_lines[].

MODIFY li_alltext FROM lw_alltext.

ENDLOOP.

Please close the thread if your query is answered.

Regards,

Nilesh.

Read only

0 Likes
1,355

done