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: 

Internal Table

Former Member
0 Kudos
166

Hi all,

I have four fields in an internal table. three fields i have populated from dictionary tabe. For the fourth column I am assigning some random value. when I try to modify the internal table the modify operation is failed. To me, everything seems to be fine but it still fails. Could you please check and tell me where I am going wrong.

*********************************************************

----


  • Form int_table

----


form int_table .

DATA :

l_rnd_value LIKE datatype-integer2.

clear wa_ekko.

loop at i_ekko into wa_ekko.

CALL FUNCTION 'RANDOM_I2'

EXPORTING

RND_MIN = 0

RND_MAX = 3

IMPORTING

RND_VALUE = l_rnd_value.

if l_rnd_value = 0.

wa_ekko-line_color = 'C100'.

modify table i_ekko from wa_ekko .

endif.

if l_rnd_value = 1.

wa_ekko-line_color = 'C300'.

modify table i_ekko from wa_ekko .

endif.

if l_rnd_value = 2.

wa_ekko-line_color = 'C500'.

modify table i_ekko from wa_ekko .

endif.

if l_rnd_value = 3.

wa_ekko-line_color = 'C600'.

modify table i_ekko from wa_ekko .

endif.

clear wa_ekko.

endloop. " Loop ends here.

endform. " int_table

*********************************************************

Regards,

Varun.

1 ACCEPTED SOLUTION

former_member221770
Contributor
0 Kudos
149

Varun,

What is the definition of I_EKKO and WA_EKKO? DO they have the same structure?

Cheers,

Pat.

19 REPLIES 19

Former Member
0 Kudos
149

Hi Varun,

Can you try this..

loop at i_ekko.

CALL FUNCTION 'RANDOM_I2'

EXPORTING

RND_MIN = 0

RND_MAX = 3

IMPORTING

RND_VALUE = l_rnd_value.

if l_rnd_value = 0.

i_ekko-line_color = 'C100'.

modify table i_ekko index sy-tabix.

endif.

if l_rnd_value = 1.

i_ekko-line_color = 'C300'.

modify table i_ekko index sy-tabix.

endif.

if l_rnd_value = 2.

i_ekko-line_color = 'C500'.

modify table i_ekko index sy-tabix.

endif.

if l_rnd_value = 3.

i_ekko-line_color = 'C600'.

modify table i_ekko index sy-tabix .

endif.

endloop. " Loop ends here.

0 Kudos
149

Hi Phani,

This still gives the same error.Moreever you cannot specify index here. It gives an error I specify index here.

Regards,

Varun.

former_member221770
Contributor
0 Kudos
150

Varun,

What is the definition of I_EKKO and WA_EKKO? DO they have the same structure?

Cheers,

Pat.

0 Kudos
149

Hi Patrick,

*---- Types Declaration.

TYPES: BEGIN OF t_ekko ,

ebeln LIKE ekko-ebeln, " Purchasing Document Number

bukrs LIKE ekko-bukrs, " Company Code

bsart LIKE ekko-bsart, " Purchasing Document Type

ernam LIKE ekko-ernam, " Name of Person who Created

" the Object

lifnr LIKE ekko-lifnr, " Account Number of the Vendor

line_color(4) type c, " Line color

END OF t_ekko.

*---- Table Memory Allocation.

DATA i_ekko TYPE t_ekko OCCURS 0.

*---- Work area Declaration.

DATA wa_ekko LIKE LINE OF i_ekko.

I have specified the structure as above.

Regards,

Varun.

0 Kudos
149

Hi Patrick,

I think I am right.What do you say Patrick ?

Regards,

Varun.

0 Kudos
149

Hi Varun,

can you change the statement like this..

MODIFY TABLE I_EKKO FROM WA_EKKO TRANSPORTING LINE_COLOR.

0 Kudos
149

Hi Phani,

No use sy-subrc is still 4. Should I forward my whole code ?

Regards,

Varun.

0 Kudos
149

yhea can you do that...let me check the code.

0 Kudos
149

Hi phani,

*********************************************************

REPORT z_v_alv_linecolor.

*---- Type pools Declaration.

TYPE-POOLS slis.

*---- Tables declaration.

TABLES ekko. " Purchasing Document Header

  • *---- Types Declaration.

TYPES: BEGIN OF t_ekko ,

ebeln LIKE ekko-ebeln, " Purchasing Document Number

bukrs LIKE ekko-bukrs, " Company Code

bsart LIKE ekko-bsart, " Purchasing Document Type

ernam LIKE ekko-ernam, " Name of Person who Created

" the Object

lifnr LIKE ekko-lifnr, " Account Number of the Vendor

line_color(4) type c, " Line color

END OF t_ekko.

*---- Table Memory Allocation.

DATA i_ekko TYPE t_ekko OCCURS 0.

*---- Work area Declaration.

DATA wa_ekko LIKE LINE OF i_ekko.

*data : begin of i_ekko occurs 0,

  • ebeln LIKE ekko-ebeln, " Purchasing Document Number

  • bukrs LIKE ekko-bukrs, " Company Code

  • bsart LIKE ekko-bsart, " Purchasing Document Type

  • ernam LIKE ekko-ernam, " Name of Person who Created

  • " the Object

  • lifnr LIKE ekko-lifnr, " Account Number of the Vendor

  • line_color(4) type c, " Line color

*

  • end of i_ekko.

*---- Select options declaration.

select-options ebeln for ekko-ebeln.

*---- Simulation of fieldcat.

data : ls_layout TYPE slis_layout_alv, " Layout

ls_fieldcat TYPE slis_fieldcat_alv, " Workarea

lt_fieldcat TYPE slis_t_fieldcat_alv, " Table

colpos type i value 0.

*---- Data selection into i_mara

select ebeln

bukrs

bsart

ernam

lifnr from

ekko into table i_ekko.

perform int_table.

perform build_fieldcat.

  • Fill Layout - Name of the field with color

ls_layout-info_fieldname = 'LINE_COLOR'.

----


  • Form build_fieldcat

----


form build_fieldcat .

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = 'Z_V_ALV_LINECOLOR'

I_INTERNAL_TABNAME = 'I_EKKO'

I_STRUCTURE_NAME = 'Z_V_ALV_LINECOLOR'

  • I_CLIENT_NEVER_DISPLAY = 'X'

  • I_INCLNAME =

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

CHANGING

ct_fieldcat = lt_fieldcat

  • EXCEPTIONS

  • INCONSISTENT_INTERFACE = 1

  • PROGRAM_ERROR = 2

  • OTHERS = 3

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

endform. " build_fieldcat

----


  • Form int_table

----


form int_table .

DATA :

l_rnd_value LIKE datatype-integer2.

*clear wa_ekko.

loop at i_ekko into wa_ekko.

CALL FUNCTION 'RANDOM_I2'

EXPORTING

RND_MIN = 0

RND_MAX = 3

IMPORTING

RND_VALUE = l_rnd_value.

if l_rnd_value = 0.

wa_ekko-line_color = 'C100'.

MODIFY TABLE I_EKKO FROM WA_EKKO TRANSPORTING LINE_COLOR.

endif.

if l_rnd_value = 1.

wa_ekko-line_color = 'C300'.

MODIFY TABLE I_EKKO FROM WA_EKKO TRANSPORTING LINE_COLOR.

endif.

if l_rnd_value = 2.

wa_ekko-line_color = 'C500'.

MODIFY TABLE I_EKKO FROM WA_EKKO TRANSPORTING LINE_COLOR.

endif.

if l_rnd_value = 3.

wa_ekko-line_color = 'C600'.

MODIFY TABLE I_EKKO FROM WA_EKKO TRANSPORTING LINE_COLOR.

endif.

clear wa_ekko.

endloop. " Loop ends here.

endform. " int_table

*********************************************************

Regards,

Varun.

0 Kudos
149

Looks ok to me...do what Phiani said with the TRANSPORTING clause, but it looks good to me. Just tried it on my computer and it works fine...

0 Kudos
149

Hi Varun,

Its working fine for me.just check whether you are getting data in your internal table i_ekko from your sleect statement.I can see no where clause in the select.

select ebeln

bukrs

bsart

ernam

lifnr from

ekko into table i_ekko

<b>where ebeln = ebeln."your select-option.</b>

0 Kudos
149

Hi Varun,

Since you have opened the loop, you should not specify table.. just use MODIFY i_ekko from wa_ekko and you will be good to go.

Regards,

Suresh Datti

0 Kudos
149

Hi,

Guys go through the program in this link I am trying to do the same.

<b>http://www.geocities.com/mpioud/Z_ALV_LINE_COLOR.html</b>

When I copy the program from site and execute it it

works fine. But when I modify a little it doesn't work.

Regards,

Varun.

0 Kudos
149

I think Suresh has got it! Well spotted!

0 Kudos
149

Just use modify i_ekko from wa_ekko transporting line_color.

0 Kudos
149

Hi,

Thank you all guys. Finally Suresh Datti got it. Anyway thanks you all for trying to help me.

Regards,

Varun.

0 Kudos
149

Try this.


*---------------------------------------------------------------------*
* Form int_table
*---------------------------------------------------------------------*
form int_table .

  DATA: l_rnd_value LIKE datatype-integer2.

  clear wa_ekko.

  loop at i_ekko into wa_ekko.
    CALL FUNCTION 'RANDOM_I2'
      EXPORTING
        RND_MIN = 0
        RND_MAX = 3
      IMPORTING
        RND_VALUE = l_rnd_value.

    case l_rnd_value.
      when 0.
        wa_ekko-line_color = 'C100'.
      when 1.
        wa_ekko-line_color = 'C300'.
      when 2.
        wa_ekko-line_color = 'C500'.
      when 3.
        wa_ekko-line_color = 'C600'.
    endcase. 
    MODIFY I_EKKO FROM WA_EKKO.
    clear wa_ekko.
  endloop. " Loop ends here.

endform. " int_table

Former Member
0 Kudos
149

Exactly what happens when it fails? Dump, return code?

Rob

0 Kudos
149

Hi Rob,

Sy-subrc returns 4. And the table is not modified.

Regards,

Varun.