ERP Database - The Unofficial ERP Knowledge Base

Facebook Twitter del.icio.us Digg it
ERP Database contains a huge collection of articles related to ERP System and Software. Many of the articles are specifically related to SAP. All these ERP/SAP articles are freely available to everyone.

If you would like to submit an article or share any document related to ERP or any specific ERP software. Please mail it to support@erpdb.info. Please make sure that the documents are not copyrighted.
Social Bookmarks:

Use of Commit and Rollback

Print This Post Email This Post Written by admin on Oct 27th, 2007 | Filed under: ABAP Programs

REPORT Z_IMPORT_EXPORT_to_cluster NO STANDARD PAGE HEADING.
TABLES : ZGLGRP , SKB1.
PARAMETERS : IFILE(30) DEFAULT ‘/tmp/cdslink.dat’ LOWER CASE,
PBUKRS LIKE BKPF-BUKRS ,
PKTOPL LIKE ZGLGRP-KTOPL.
DATA : BEGIN OF TAB1 OCCURS 100 ,
NEWGL(6) ,
OLDGL(4) ,
LINK(2) ,
END OF TAB1.
DATA : BEGIN OF TAB2 OCCURS 100.
INCLUDE STRUCTURE ZGLGRP.
DATA : END OF TAB2.
DATA : LIN(4) TYPE N ,
GLOK(1) VALUE ‘N’ ,
GL10(10) ,

START-OF-SELECTION.
OPEN DATASET IFILE FOR INPUT IN TEXT MODE.

DO.
CLEAR TAB1.
READ DATASET IFILE INTO TAB1.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
PERFORM GET_GLOK.
IF GLOK = ‘Y’.
CLEAR TAB2.
MOVE : SY-MANDT TO TAB2-MANDT , PKTOPL TO TAB2-KTOPL ,
PBUKRS TO TAB2-BUKRS , GL10 TO TAB2-HKONT ,
TAB1-LINK TO TAB2-ZCDSGRP.
APPEND TAB2.
ELSE.
APPEND TAB1.
ENDIF.
ENDDO.
END-OF-SELECTION.
*
MODIFY ZGLGRP FROM TABLE TAB2.
DESCRIBE TABLE TAB2 LINES LIN.
IF LIN NE SY-DBCNT.
LIN = LIN – SY-DBCNT.
ROLLBACK WORK.
WRITE :/2 ‘Update Failed For ‘ , LIN ,
‘ Records. Table ROLLED BACK Entirely’.
ELSE.
COMMIT WORK.
ENDIF.
*
CLEAR LIN.
DESCRIBE TABLE TAB1 LINES LIN.
IF LIN > 0.
WRITE :/2 ‘Reocrds Not Updated ‘. ULINE /2(25).
LOOP AT TAB1.
WRITE :/4 TAB1-NEWGL , TAB1-LINK .
ENDLOOP.
ENDIF.

FORM GET_GLOK.
MOVE ‘N’ TO GLOK.
CLEAR GL10. MOVE : ’0000′ TO GL10 , TAB1-NEWGL TO GL10+4(6).
SELECT SINGLE * FROM SKB1 WHERE BUKRS = PBUKRS
AND SAKNR = GL10.
IF SY-SUBRC EQ 0.
MOVE ‘Y’ TO GLOK.
ENDIF.
ENDFORM.

Source : Planet sap
———————
ABAPer, mail: abap.community@gmail.com http://www.erpdb.info

Share

If you like this post, you may as well like these too:

  1. COMMIT: ABAP Keyword a day COMMITBasic formCOMMIT WORK.Addition… AND WAITEffectExecutes a database commit and thus closes a logical processing unit or Logical Unit of Work ( LUW ) (see also Transaction processing ). This means...



Leave a Reply