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: 

Modify dynamic internal table from dynamic work area using index...

Former Member
0 Kudos

ASSIGN w_text TO <fs>.

ASSIGN w_temp TO <fs1>.

lint_tab_iw49[] = <tab>.

lint_tab_iw49_t[] = <tab>.

DELETE ADJACENT DUPLICATES FROM lint_tab_iw49 COMPARING aufnr.

LOOP AT lint_tab_iw49 INTO lws_tab_iw49.

READ TABLE lint_object_tab1 INTO lws_object_tab1

WITH KEY aufnr = lws_tab_iw49-aufnr.

IF sy-subrc EQ 0.

  • Collect operations in rows of an internal table.

w_idx = 1.

WHILE w_idx < 51.

w_nn = w_idx.

CONCATENATE 'lws_object_tab1-ZZOPERN' w_nn INTO w_xx.

ASSIGN (w_xx) TO <fs>.

CONCATENATE w_text <fs> INTO w_text SEPARATED BY ','.

w_idx = w_idx + 1.

ENDWHILE.

  • Split operations into an internal table to get operations in rows.

SPLIT w_text AT ',' INTO TABLE lint_vornr.

DELETE lint_vornr WHERE vornr = ' '.

DESCRIBE TABLE lint_vornr LINES w_lines.

  • Collect costs in rows of an internal table

CLEAR: w_idx, w_nn, w_xx, w_text.

w_idx = 1.

WHILE w_idx < 51.

w_nn = w_idx.

CONCATENATE 'lws_object_tab1-ZZCOST' w_nn INTO w_xx.

ASSIGN (w_xx) TO <fs>.

<fs1> = <fs>.

CONCATENATE w_text <fs1> INTO w_text SEPARATED BY ','.

w_idx = w_idx + 1.

ENDWHILE.

  • Split costs into an internal table to get costs in rows.

SPLIT w_text AT ',' INTO TABLE lint_escost.

DELETE lint_escost WHERE cost = ' '.

DESCRIBE TABLE lint_escost LINES w_lines_cost.

  • Append lines of lint_escost from 1 to w_lines to lint_escost1.

  • Collect currencies in rows of an internal table

CLEAR: w_idx, w_nn, w_xx, w_text.

w_idx = 1.

WHILE w_idx < 51.

w_nn = w_idx.

CONCATENATE 'lws_object_tab1-ZZCURR' w_nn INTO w_xx.

ASSIGN (w_xx) TO <fs>.

<fs1> = <fs>.

CONCATENATE w_text <fs1> INTO w_text SEPARATED BY ','.

w_idx = w_idx + 1.

ENDWHILE.

  • Split costs into an internal table to get costs in rows.

SPLIT w_text AT ',' INTO TABLE lint_curr.

DELETE lint_curr WHERE curr = ' '.

DESCRIBE TABLE lint_curr LINES w_lines_curr.

  • Append lines of lint_curr from 1 to w_lines to lint_curr1.

ENDIF.

PERFORM update_object_tab_for_iw49n.

ENDLOOP.

ENDIF.

ENDFORM. " modify_object_tab

*&----


*

*& Form update_object_tab_for_IW49N

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

FORM update_object_tab_for_iw49n .

DATA: lws_temp TYPE string VALUE 'where aufnr = lws_tab_iw49-aufnr',

lw_index TYPE sy-index.

READ TABLE <tab> TRANSPORTING NO FIELDS WITH KEY ('AUFNR') =

lws_tab_iw49-aufnr.

IF sy-subrc EQ 0.

lw_index = sy-tabix.

LOOP AT <tab> INTO <wa1> FROM lw_index.

IF <wa1>-aufnr NE lws_tab_iw49-aufnr.

EXIT.

ELSE.

CLEAR lw_index.

  • lw_index = sy-tabix.

lw_index = 1.

WHILE lw_index LE w_lines.

READ TABLE lint_escost INTO lws_escost INDEX lw_index.

IF sy-subrc EQ 0.

  • lw_index = lw_index + 1.

<wa1>-zzcost1 = lws_escost-cost.

ENDIF.

READ TABLE lint_curr1 INTO lws_curr INDEX lw_index.

IF sy-subrc EQ 0.

<wa1>-zzcurr1 = lws_curr-curr.

ENDIF.

MODIFY <tab> FROM <wa1> "TRANSPORTING ('ZZCOST1') ('ZZCURR1')

INDEX sy-tabix.

IF sy-subrc EQ 0.

ENDIF.

lw_index = lw_index + 1.

ENDWHILE.

ENDIF.

ENDLOOP.

ENDIF.

ENDFORM. " update_object

Hi,

With referene to the code snippet above I want to modify <tab> from <wa1> on specific indices or with specific where condition.

Is it achievable... How?

Many thanks in advance.

Thanks & Regards,

Shreya

1 REPLY 1

Former Member
0 Kudos

You might have to split the code in to two parts to keep the formatting intact.