Hi Kabil,
I understood the problem is only during updating the Ztable 'ZSEMI', that's why we given the suggestions above. Please let me know whether you have tried the above suggestions.
Kindly confirm the following fields are available in ZCALC Table. As per the structure defined above in ty_data and ty_data1, it is found difference in field structure.
- fgdes
- docnum
- ersda
- werks
- pbw
- pbv
- tcost
- control
- gcost
- pbvcost
- pbwcost
- contri
I have more number of questions in this program,
- Is the above fields are available in ZCALC Table.
- Table Control points to which internal Table - IT_DATA or IT_DATA1
- If it points to IT_DATA means, why the above fields are not declared in TY_DATA structure.
- If Table control points to IT_DATA1, then we should mention the outer loop as IT_DATA1 instead of IT_DATA.
In order to better analysis, Kindly share the below.
1. FLOW Logic screenshot.
2. Download the program using REPTRAN(from SE38), remove checkbox tick mark 'ABAP Code Only'
3. ZTable structure ZCALC, ZSEMI from SE11.
Code written below as per above program:
If IT_DATA1 and Table control are same structure the below code works.
Kindly make sure the program is activated without any errors and also in debugger, also confirm the value is passing in IT_DATA1 which is same as Table Control.
DATA: l_del TYPE I value 0,
l_rec_exist TYPE I value 0,
l_ins_mod TYPE I value 0,
l_ins_new TYPE I value 0.
CASE ok_code.
WHEN 'SAVE'.
LOOP AT it_data1 INTO wa_data1.
gs_data-rmcode = wa_data1-rmcode.
gs_data-matnr = wa_data1-matnr.
gs_data-werks = wa_data1-werks.
gs_data-specg = wa_data1-specg.
gs_data-cost = wa_data1-cost.
gs_data-solid = wa_data1-solid.
gs_data-resin = wa_data1-resin.
gs_data-crossl = wa_data1-crossl.
gs_data-pigment = wa_data1-pigment.
gs_data-extendl = wa_data1-extendl.
gs_data-catalyst = wa_data1-catalyst.
gs_data-solvent = wa_data1-solvent.
gs_data-aerosil = wa_data1-aerosil.
gs_data-wax = wa_data1-wax.
gs_data-anti = wa_data1-anti.
gs_data-other = wa_data1-other.
gs_data-costm = wa_data1-costm.
gs_data-variance = wa_data1-variance.
gs_data-verpr = wa_data1-verpr.
gs_data-fgdes = wa_data1-fgdes.
gs_data-docnum = wa_data1-docnum.
gs_data-ersda = wa_data1-ersda.
gs_data-pbw = wa_data1-pbw.
gs_data-pbv = wa_data1-pbv.
gs_data-tcost = wa_data1-tcost.
gs_data-control = wa_data1-control.
"Use select statement and check whether we have existing record.
SELECT SINGLE FGDES
DOCNUM
FROM ZSEMI INTO (L_FGDES, L_DOCNUM)
WHERE FGDES = GS_DATA-FGDES
AND DOCNUM = GS_DATA-DOCNUM.
IF SY-SUBRC = 0.
l_rec_exist = 1.
"If existing record available, delete the old record and append the new one
DELETE ZSEMI WHERE FGDES = GS_DATA-FGDES
AND DOCNUM = GS_DATA-DOCNUM.
IF SY-SUBRC = 0 .
L_DEL = 1.
"Append the new record, Use Either Insert or Modify statement
MODIFY ZSEMI FROM GS_DATA.
IF SY-SUBRC = 0.
COMMIT WORK.
L_INS_MOD = 1.
ELSE.
L_INS_MOD = 0.
ENDIF.
ELSE.
L_DEL = 0.
ENDIF.
ELSE.
L_REC_EXIST = 0.
"Append the new record, Use Either Insert or Modify statement
MODIFY ZSEMI FROM GS_DATA.
IF SY-SUBRC = 0.
L_INS_NEW = 1.
COMMIT WORK.
ELSE.
L_INS_NEW = 0.
ENDIF.
ENDIF.
BREAK-POINT.
CLEAR: L_REC_EXIST, L_INS_MOD, L_INS_NEW, L_DEL.
ENDLOOP.
ENDCASE.
The following variables are used to cross verify the program during debugging session, Kindly debug the same.
- L_REC_EXIST
- L_INS_MOD
- L_INS_NEW
- L_DEL
If still problem exist, show the screenshot in Debugger mode, place the cursor in Break point and show the the above values
Regards
Rajkumar Narasimman.