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 statement

Former Member
0 Likes
961

hi friends,

in my report i use a itab which can be filled then i call FM and again i try to fill it again by using modify table from work area index sy-tabix. but it goes in dump saying index 0 is not allowed.

kindly help me out.

thanks

1 ACCEPTED SOLUTION
Read only

Mohamed_Mukhtar
Active Contributor
0 Likes
934

hi,

try like this

LOOP AT it INTO wa.
  wa_fieldname = <somevalue>.
  tbx = sy-tabix.
  MODIFY it INDEX tbx  FROM wa  TRANSPORTING fieldname.
CLEAR tbx.
ENDLOOP.

Thanks & Regards

8 REPLIES 8
Read only

Former Member
0 Likes
934

Hi ,

This should work perfectly if the code is to be wrtten inside a loop.If not please do explicitly mention the index number.

Varghese

Read only

Former Member
0 Likes
934

Can u paste the part of the code here .. to understand better.

Guru.

Read only

0 Likes
934

LOOP AT T_OUTPUT1 INTO W_OUTPUT1.

CALL FUNCTION 'Z_CHECK_STOCK_BATCH'

EXPORTING

P_CHARG = W_OUTPUT1-CHG

  • P_CHARG = P_CHARG

IMPORTING

COUNT = V_CNT

COUNT1 = V_CNT1 .

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

          • if stock is awailable fill table t_batch and proceed with new batch

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

IF V_CNT <> 0 OR V_CNT1 <> 0.

********for getting quqntity field************************************

**%%$%$%$%%$%$%$%$%$%$%%$%$%$%%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%

SELECT CLABS CUMLM CINSM CSPEM CRETM CVMLA CVMUM

FROM MCHB INTO W_MCHB

WHERE CHARG = W_OUTPUT1-CHG.

APPEND W_MCHB TO T_MCHB.

SUM1 = W_MCHB-CLABS + W_MCHB-CUMLM + W_MCHB-CINSM + W_MCHB-CSPEM + W_MCHB-CRETM + W_MCHB-CVMLA

+ W_MCHB-CVMUM .

SUM1 = SUM1 + W_MCHB-SUM2.

W_MCHB-SUM2 = SUM1.

MODIFY T_MCHB FROM W_MCHB INDEX SY-TABIX.

ENDSELECT.

SELECT KALAB KAINS KASPE

FROM MSKA INTO W_MSKA

WHERE CHARG = W_OUTPUT1-CHG.

APPEND W_MSKA TO T_MSKA.

SUM1 = W_MSKA-KALAB + W_MSKA-KAINS + W_MSKA-KASPE.

SUM1 = SUM1 + W_MSKA-SUM2.

W_MSKA-SUM2 = SUM1.

MODIFY T_MSKA FROM W_MSKA INDEX SY-TABIX.

ENDSELECT.

W_BATCH-SUM2 = W_MCHB-SUM2 + W_MSKA-SUM2.

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

          • fetch data and count from Sales Order Stock (MSKA)

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

  • SELECT KALAB KAINS KASPE FROM MSKA .

********for getting quqntity field************************************

W_BATCH-I_BATCH = W_OUTPUT1-CHG.

W_BATCH-S_BATCH = W_OUTPUT1-CHG.

W_BATCH-BUDAT1 = W_OUTPUT1-ERSDA.

W_BATCH-MAKTX = W_OUTPUT1-MAKTX.

W_BATCH-MENGE = W_OUTPUT1-MENGE.

W_BATCH-MEINS = W_OUTPUT1-MEINS.

W_BATCH-BUDAT = W_OUTPUT1-ERSDA.

APPEND W_BATCH TO T_BATCH.

CLEAR : W_MCHB, W_MSKA, T_MCHB, T_MSKA.

CONTINUE.

  • EXIT.

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

          • if stock is not awailable fill table t_output and proceed

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

ENDIF.

W_OUTPUT-MTR = W_OUTPUT1-MTR.

W_OUTPUT-CHG = W_OUTPUT1-CHG.

W_OUTPUT-ERSDA = W_OUTPUT1-ERSDA.

W_OUTPUT-MENGE = W_OUTPUT1-MENGE.

W_OUTPUT-MEINS = W_OUTPUT1-MEINS.

W_OUTPUT-MAKTX = W_OUTPUT1-MAKTX.

APPEND W_OUTPUT TO T_OUTPUT.

ENDLOOP.

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

LOOP AT T_OUTPUT INTO W_OUTPUT.

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

    • Fm to get next batch

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

CALL FUNCTION 'ZFIND_PRDORD_FOR_BATCH_1'

EXPORTING

IP_CHARG = W_OUTPUT-CHG

  • IP_AUFNR =

  • IP_EBELN =

  • IP_EBELP =

  • IP_AUFPS =

  • IP_UMCHA =

  • IP_TOEXIT =

  • IP_EXCHA =

  • IP_BUDAT =

IMPORTING

  • P_CHARG =

  • P_MBLNR =

  • P_MLBCHGP = T_OT1

P_TOEXIT = V_TOEXIT

P_EXCHA = T_CHG

P_BUDAT = V_BUDAT

  • TABLES

  • H_BATCH =

  • R_BATCH = T_BUDAT2

CHANGING

  • S_MLBCHGP =

S_CHGDT = T_BUDAT1 .

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

DATA : A TYPE I.

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

LOOP AT T_BUDAT1 INTO W_BUDAT1.

W_FTAB-MANDT = SY-MANDT.

W_FTAB-ICHARG = W_OUTPUT-CHG. "Initial batch

W_FTAB-BUDAT1 = W_OUTPUT-ERSDA. "Initial batch date created on

W_FTAB-FCHARG = W_BUDAT1-CHARG. "last batch which is empty

W_FTAB-BUDAT = W_BUDAT1-BUDAT. "last batch date on which fully consumed

W_FTAB-VBELN = W_BUDAT1-VBELN. "delevery document no of batch

APPEND W_FTAB TO T_FTAB .

ENDLOOP.

SORT T_FTAB BY BUDAT DESCENDING .

READ TABLE T_FTAB INDEX 1 INTO W_FTAB. "Get max date of delevery from is row

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

          • If value of v_toexit is Y it means there is stock in batch

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

W_BATCH-I_BATCH = W_OUTPUT-CHG. " Initial batch

W_BATCH-S_BATCH = T_CHG. " last batch

W_BATCH-BUDAT1 = W_OUTPUT-ERSDA. " last date of batch

W_BATCH-MENGE = W_OUTPUT-MENGE.

W_BATCH-MEINS = W_OUTPUT-MEINS.

W_BATCH-MAKTX = W_OUTPUT-MAKTX.

W_BATCH-BUDAT = W_FTAB-BUDAT. " Posting date in document

W_BATCH-VBELN = W_FTAB-VBELN. " delevery document no.

IF NOT V_BUDAT IS INITIAL.

W_BATCH-BUDAT = V_BUDAT. " Posting date in document

ENDIF.

MODIFY T_BATCH FROM W_BATCH INDEX 1. Getting Error here

  • APPEND W_BATCH TO T_BATCH.

  • CONTINUE.

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

          • If v_toexit is empty it means there is no stock in batch fullly consumed

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

ENDLOOP.

Read only

0 Likes
934

Hi,

Try with SY-TABIX.

or ..

if the Existing value from the internal table t_batch-i_batch is = w_output-chg

then u can use

modify it from wa transporting 'fieldname'.

Edited by: Guru Ram on Mar 24, 2009 8:34 AM

Read only

0 Likes
934

MODIFY gt_table2 FROM gs_table2 INDEX sy-tabix.

or

while reading gs-table2

store the index in one variable

MODIFY gt_table2 FROM gs_table2 INDEX "variable".

Try this

Read only

Former Member
0 Likes
934

check the index and modify,

Read only

Mohamed_Mukhtar
Active Contributor
0 Likes
935

hi,

try like this

LOOP AT it INTO wa.
  wa_fieldname = <somevalue>.
  tbx = sy-tabix.
  MODIFY it INDEX tbx  FROM wa  TRANSPORTING fieldname.
CLEAR tbx.
ENDLOOP.

Thanks & Regards

Read only

Former Member
0 Likes
934

use

MODIFY itab INDEX sy-tabix.