12-13-2007 9:21 AM
hi guyz ,
i wanna update the table with cancellation code in the table...this is my code..structure contains the updated field but table doesnt...
LOOP AT gt_header INTO gs_header.
IF NOT gs_header-to_number IS INITIAL.
gs_header-canx_code = '99'.
ELSE.
gs_header-canx_code = '00'.
ENDIF.
ENDLOOP.
CHECK NOT gt_header[] IS INITIAL.
UPDATE ztcptab_orderhdr FROM TABLE gt_header.
IF sy-subrc = 0.
COMMIT WORK AND WAIT.
ENDIF.
Thanks
12-13-2007 9:40 AM
hi
try like this if u have multiple records in gt_header
create another internal table <b>gt_header1</b> of type gt_header.
______________________________________________________________
LOOP AT gt_header INTO gs_header.
IF NOT gs_header-to_number IS INITIAL.
gs_header-canx_code = '99'.
ELSE.
gs_header-canx_code = '00'.
ENDIF.
append gs_header to gt_header1.
ENDLOOP.
CHECK NOT <b>gt_header1[]</b> IS INITIAL.
UPDATE ztcptab_orderhdr FROM TABLE <b>gt_header1</b>.
IF sy-subrc = 0.
COMMIT WORK AND WAIT.
ENDIF.
______________________________________________________________
regards
vijay
<b>reward points if helpfull</b>
12-13-2007 9:25 AM
You need to modify the internal table first with structure.
LOOP AT gt_header INTO gs_header.
IF NOT gs_header-to_number IS INITIAL.
gs_header-canx_code = '99'.
ELSE.
gs_header-canx_code = '00'.
ENDIF.
<b>modify gt_header by gs_header transporting canx_code.</b>
ENDLOOP.
12-13-2007 9:30 AM
Hi,
Try like this
&----
*& Form SUB_READ_UPDATE_BSEG
&----
text
----
FORM sub_read_update_bseg.
IF NOT it_final[] IS INITIAL.
LOOP AT it_final INTO wa_final.
UPDATE bseg SET zuonr = wa_final-ccnum
WHERE bukrs EQ wa_final-bukrs
AND belnr EQ wa_final-vbeln
AND rfzei EQ wa_final-rfzei
AND saknr NE ' '.
ENDLOOP.
*--Message data updated successfully
MESSAGE i888 WITH text-002.
LEAVE LIST-PROCESSING.
ELSE.
*--Message No data found
MESSAGE i888 WITH text-003.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. " SUB_READ_UPDATE_BSEG
Regards,
Prashant
12-13-2007 9:30 AM
Hi Sudheer,
Try this,
LOOP AT gt_header INTO gs_header.
IF NOT gs_header-to_number IS INITIAL.
gs_header-canx_code = '99'.
ELSE.
gs_header-canx_code = '00'.
ENDIF.
ENDLOOP.
CHECK NOT gt_header[] IS INITIAL.
MODIFY ztcptab_orderhdr FROM gt_header.
IF sy-subrc = 0.
COMMIT WORK AND WAIT.
ENDIF.
Please make sure that before modifying , you use dequeue and enqueue to avoid locking of tables.
Reward if useful.
Regards,
Chitra
12-13-2007 9:37 AM
Use Modify statement instead of Update and lock the table using Enque before modifying it.
12-13-2007 9:40 AM
hi
try like this if u have multiple records in gt_header
create another internal table <b>gt_header1</b> of type gt_header.
______________________________________________________________
LOOP AT gt_header INTO gs_header.
IF NOT gs_header-to_number IS INITIAL.
gs_header-canx_code = '99'.
ELSE.
gs_header-canx_code = '00'.
ENDIF.
append gs_header to gt_header1.
ENDLOOP.
CHECK NOT <b>gt_header1[]</b> IS INITIAL.
UPDATE ztcptab_orderhdr FROM TABLE <b>gt_header1</b>.
IF sy-subrc = 0.
COMMIT WORK AND WAIT.
ENDIF.
______________________________________________________________
regards
vijay
<b>reward points if helpfull</b>