Skip to Content
0
Former Member
Aug 03, 2006 at 07:38 PM

What is wrong in this code?

62 Views

This code, has to set the status of the document as 'AD' , then change some data save it and again set the status to RE. WHen i run this in debug mode , it actually updates everything , but when i dont go in the debug mode , it just updates the first status set to 'AD' and then doesnt do anything ...any insights why ?

CALL FUNCTION 'BAPI_DOCUMENT_SETSTATUS'

EXPORTING

DOCUMENTTYPE = 'SWD'

DOCUMENTNUMBER = ITAB-DOKNR

DOCUMENTPART = ITAB-DOKAR

DOCUMENTVERSION = ITAB-DOKVR

  • STATUSEXTERN = ' '

STATUSINTERN = 'AD'

  • STATUSLOG = ' '

IMPORTING

RETURN = RETURN

.

*

  • CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT =

  • IMPORTING

  • RETURN =

  • .

  • IF SY-SUBRC = 0.

    COMMIT WORK.

    BAPI_DATA-AUTHORITYGROUP = 'VIEW'.

    BAPI_DATA_X-AUTHORITYGROUP = 'X'.

    CALL FUNCTION 'BAPI_DOCUMENT_CHANGE2'

    EXPORTING

    DOCUMENTTYPE = 'SWD'

    DOCUMENTNUMBER = itab-doknr

    DOCUMENTPART = itab-dokar

    DOCUMENTVERSION = itab-dokvr

    DOCUMENTDATA = BAPI_DATA

    DOCUMENTDATAX = BAPI_DATA_X

    • HOSTNAME =

    • DOCBOMCHANGENUMBER =

    • DOCBOMVALIDFROM =

    • DOCBOMREVISIONLEVEL =

    • SENDCOMPLETEBOM = ' '

    • PF_FTP_DEST = ' '

    • PF_HTTP_DEST = ' '

    • CAD_MODE = ' '

    IMPORTING

    RETURN = RETURN.

    • TABLES

    • CHARACTERISTICVALUES =

    • CLASSALLOCATIONS =

    • DOCUMENTDESCRIPTIONS =

    • OBJECTLINKS =

    • DOCUMENTSTRUCTURE =

    • DOCUMENTFILES =

    • LONGTEXTS =

    • COMPONENTS =

    .

    IF SY-SUBRC = 0.

    COMMIT WORK.

    ELSE.

    ROLLBACK WORK.

    ENDIF.

    CALL FUNCTION 'BAPI_DOCUMENT_SETSTATUS'

    EXPORTING

    DOCUMENTTYPE = 'SWD'

    DOCUMENTNUMBER = ITAB-DOKNR

    DOCUMENTPART = ITAB-DOKAR

    DOCUMENTVERSION = ITAB-DOKVR

    • STATUSEXTERN = ' '

    STATUSINTERN = 'RE'

    • STATUSLOG = ' '

    IMPORTING

    RETURN = RETURN

    .

    if sy-subrc = 0 .

    commit work.

    else.

    rollback work.

    endif.

    ELSE.

    ROLLBACK WORK.

    ENDIF.

    ENDLOOP.