Skip to Content
author's profile photo Former Member
Former Member

HELP ME OUT

hi to all experts

when i use mode 'A' in call transaction records are inserted into database and sy-subrc is zero but wen i

use mode 'N' it is giving error and sy-subrc is 1.001.

can anyone explain me the reason for this error

REPORT ZSESSION NO STANDARD PAGE HEADING LINE-SIZE 56.

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

  • TYPES DECLARATION

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

TYPES : BEGIN OF TY_CUST,

KUNNR(10),

BUKRS(4),

KTOKD(4),

ANRED(15),

NAME1(35),

SORTL(10),

STRAS(35),

ORT01(10),

PSTLZ(10),

LAND1(3),

LZONE(10),

SPRAS(2),

AKONT(10),

END OF TY_CUST.

TYPES: BEGIN OF TY_ECUST,

KUNNR(10),

ERRORMSG(255),

END OF TY_ECUST.

TYPES: BEGIN OF TY_SCUST,

KUNNR(10),

SUCESSMSG(255),

END OF TY_SCUST.

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

  • INTERNAL TABLE AND WORK AREAS

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

DATA : IT_CUST TYPE STANDARD TABLE OF TY_CUST INITIAL SIZE 0,

  • RAW_DATA TYPE TABLE OF TY_CUST,

  • W_RAW_DATA LIKE LINE OF RAW_DATA,

WA_CUST LIKE LINE OF IT_CUST.

DATA: IT_ECUST TYPE TABLE OF TY_ECUST,

WA_ECUST LIKE LINE OF IT_ECUST.

DATA : IT_SCUST TYPE TABLE OF TY_SCUST,

WA_SCUST LIKE LINE OF IT_SCUST.

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

  • INTERANAL TABLE FOR STORING BDCDATA

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

DATA: BEGIN OF IT_BDCDATA OCCURS 0.

INCLUDE STRUCTURE BDCDATA.

DATA: END OF IT_BDCDATA.

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

  • INTERNAL TABLE FOR STORING MESSAGES

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

DATA: BEGIN OF IT_CUSTMSG OCCURS 0.

INCLUDE STRUCTURE BDCMSGCOLL.

DATA: END OF IT_CUSTMSG.

DATA: V_FLAG(1) VALUE '',"FLAG FOR OPENING OF SESSION

V_TLINES TYPE SY-TABIX,"TOTAL NO RECORDS PROCESSED

V_SLINES TYPE SY-TABIX,"TOTAL NO OF SUCESS RECORDS PROCESSED

V_ELINES TYPE SY-TABIX."TOTAL NO OF ERROR RECORDS

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

  • SELECTION SCREEN

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

SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-001.

PARAMETERS : V_FNAME TYPE RLGRAP-FILENAME,

V_SESS TYPE RLGRAP-FILENAME.

SELECTION-SCREEN END OF BLOCK B2.

INITIALIZATION.

V_FNAME = 'C:\Documents and Settings\Administrator\Desktop\2.TXT'.

TOP-OF-PAGE.

WRITE: / 'DETAILS OF ALL SESSIONS'.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR V_FNAME.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

FIELD_NAME = ' '

IMPORTING

FILE_NAME = V_FNAME

.

START-OF-SELECTION.

PERFORM F_UPLOAD USING V_FNAME

CHANGING IT_CUST.

END-OF-SELECTION.

PERFORM F_BDCGENERATE.

PERFORM F_WRITE_TOP.

&----


*& Form F_UPLOAD

&----


  • text

----


  • -->P_V_FNAME text

  • <--P_IT_CUST text

----


FORM F_UPLOAD USING P_V_FNAME LIKE V_FNAME

CHANGING P_IT_CUST LIKE IT_CUST.

DATA: LV_FILE TYPE STRING.

LV_FILE = P_V_FNAME.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = LV_FILE

TABLES

DATA_TAB = P_IT_CUST

.

IF SY-SUBRC = 0.

DESCRIBE TABLE P_IT_CUST LINES V_TLINES.

ENDIF.

*

*CALL FUNCTION 'TEXT_CONVERT_CSV_TO_SAP'

  • EXPORTING

  • I_FIELD_SEPERATOR = ';'

  • I_LINE_HEADER =

  • I_TAB_RAW_DATA = P_IT_CUST

  • I_FILENAME = 'C:\Documents and Settings\Administrator\Desktop\2.TXT'

  • TABLES

  • I_TAB_CONVERTED_DATA = P_IT_CUST

  • EXCEPTIONS

  • CONVERSION_FAILED = 1

  • OTHERS = 2

  • .

  • *IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    *ENDIF.

    ENDFORM. " F_UPLOAD

    &----


    *& Form F_BDCGENERATE

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM F_BDCGENERATE .

    LOOP AT IT_CUST INTO WA_CUST.

    SPLIT WA_CUST AT ';' INTO WA_CUST-KUNNR

    WA_CUST-BUKRS

    WA_CUST-KTOKD

    WA_CUST-ANRED

    WA_CUST-NAME1

    WA_CUST-SORTL

    WA_CUST-STRAS

    WA_CUST-ORT01

    WA_CUST-PSTLZ

    WA_CUST-LAND1

    WA_CUST-LZONE

    WA_CUST-SPRAS

    WA_CUST-AKONT.

    perform F_POPULATE_BDC using:

    'X' 'SAPMF02D' '0100',

    ' ' 'BDC_CURSOR' 'RF02D-KTOKD',

    ' ' 'BDC_OKCODE' '/00',

    ' ' 'RF02D-KUNNR' WA_CUST-KUNNR,

    ' ' 'RF02D-BUKRS' WA_CUST-BUKRS,

    ' ' 'RF02D-KTOKD' WA_CUST-KTOKD,

    • 'X' 'SAPLSHL2' '1600',

    • ' ' 'BDC_CURSOR' 'HELP_INFO-DYNPPROG',

    • ' ' 'BDC_OKCODE' '=TCAL',

    'X' 'SAPMF02D' '0110',

    ' ' 'BDC_CURSOR' 'KNA1-SPRAS',

    ' ' 'BDC_OKCODE' '/00',

    ' ' 'KNA1-ANRED' WA_CUST-ANRED,

    ' ' 'KNA1-NAME1' WA_CUST-NAME1,

    ' ' 'KNA1-SORTL' WA_CUST-SORTL,

    ' ' 'KNA1-STRAS' WA_CUST-STRAS,

    ' ' 'KNA1-ORT01' WA_CUST-ORT01,

    ' ' 'KNA1-PSTLZ' WA_CUST-PSTLZ,

    ' ' 'KNA1-LAND1' WA_CUST-LAND1,

    ' ' 'KNA1-SPRAS' WA_CUST-SPRAS,

    'X' 'SAPMF02D' '0120',

    ' ' 'BDC_CURSOR' 'KNA1-LZONE',

    ' ' 'BDC_OKCODE' '/00',

    ' ' 'KNA1-LZONE' WA_CUST-LZONE ,

    'X' 'SAPMF02D' '0125',

    ' ' 'BDC_CURSOR' 'KNA1-NIELS',

    ' ' 'BDC_OKCODE' '/00',

    'X' 'SAPMF02D' '0130',

    ' ' 'BDC_CURSOR' 'KNBK-BANKS(01)',

    ' ' 'BDC_OKCODE' '=ENTR',

    'X' 'SAPMF02D' '0340',

    ' ' 'BDC_CURSOR' 'RF02D-KUNNR',

    ' ' 'BDC_OKCODE' '=ENTR',

    'X' 'SAPMF02D' '0370',

    ' ' 'BDC_CURSOR' 'RF02D-KUNNR',

    ' ' 'BDC_OKCODE' '=ENTR',

    ' ' 'KNA1-CIVVE' 'X',

    'X' 'SAPMF02D' '0360',

    ' ' 'BDC_CURSOR' 'KNVK-NAMEV(01)',

    ' ' 'BDC_OKCODE' '=ENTR',

    'X' 'SAPMF02D' '0210',

    ' ' 'BDC_CURSOR' 'KNB1-AKONT',

    ' ' 'BDC_OKCODE' '/00',

    ' ' 'KNB1-AKONT' WA_CUST-AKONT ,

    'X' 'SAPMF02D' '0215',

    ' ' 'BDC_CURSOR' 'KNB1-ZTERM',

    ' ' 'BDC_OKCODE' '/00',

    'X' 'SAPMF02D' '0220',

    ' ' 'BDC_CURSOR' 'KNB5-MAHNA',

    ' ' 'BDC_OKCODE' '/00',

    'X' 'SAPMF02D' '0230',

    ' ' 'BDC_CURSOR' 'KNB1-VRSNR',

    ' ' 'BDC_OKCODE' '/00'.

    IF NOT IT_BDCDATA[] IS INITIAL.

    CALL TRANSACTION 'XD01' USING IT_BDCDATA[] MODE 'N' UPDATE 'A'

    MESSAGES INTO IT_CUSTMSG.

    IF SY-SUBRC NE 0.

    *POPULATING ERROR RECORDS IN AN INTERNAL TABLE

    WA_ECUST-KUNNR = WA_CUST-KUNNR.

    APPEND WA_ECUST TO IT_ECUST.

    CLEAR wa_ECUST.

    *OPENING A SESSION IF THERE IS AN ERROR RECORDS

    IF V_FLAG = ''.

    PERFORM F_OPEN_SESSION.

    V_FLAG = 'X'.

    ENDIF.

    *INSERTING ERROR RECORDS IN AN ALREADY OPEN SESSION

    IF V_FLAG = 'X'.

    PERFORM F_BDC_INSERT.

    ENDIF.

    *POPULATING SUCESS RECORDS IN AN INTERNAL TABLE

    ELSE.

    WA_SCUST-KUNNR = WA_CUST-KUNNR.

    APPEND WA_SCUST TO IT_SCUST.

    CLEAR wa_SCUST.

    ENDIF.

    *DISPLAYING THE MESSAGES

    IF NOT IT_CUSTMSG[] IS INITIAL.

    PERFORM F_FORMAT_MESSAGE.

    ENDIF.

    *CLERAING BDCDATA AND CUST MESSAGES

    CLEAR: IT_BDCDATA,IT_CUSTMSG.

    *--Getting the total no of error records.

    DESCRIBE TABLE IT_ECUST LINES V_ELINES.

    *--Getting the total no of successful records.

    DESCRIBE TABLE IT_SCUST LINES V_SLINES.

    *CLOSING A SESSION ONLY IF IT IS OPENED

    IF V_FLAG = 'X'.

    PERFORM F_CLOSE_SESSION.

    ENDIF.

    ENDIF.

    endloop.

    ENDFORM. " F_BDCGENERATE

    &----


    *& Form F_POPULATE_BDC

    &----


    • text

    ----


    • -->P_0243 text

    • -->P_0244 text

    • -->P_0245 text

    ----


    FORM F_POPULATE_BDC USING VALUE(P_0243)

    VALUE(P_0244)

    VALUE(P_0245).

    IF P_0243 = 'X'.

    IT_BDCDATA-PROGRAM = P_0244.

    IT_BDCDATA-DYNPRO = P_0245.

    IT_BDCDATA-DYNBEGIN = 'X'.

    ELSE.

    IT_BDCDATA-FNAM = P_0244.

    IT_BDCDATA-FVAL = P_0245.

    ENDIF.

    APPEND IT_BDCDATA.

    CLEAR IT_BDCDATA.

    ENDFORM. " F_POPULATE_BDC

    &----


    *& Form F_OPEN_SESSION

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM F_OPEN_SESSION .

    DATA: LV_SESSION(12).

    LV_SESSION = V_SESS.

    CALL FUNCTION 'BDC_OPEN_GROUP'

    EXPORTING

    CLIENT = SY-MANDT

    GROUP = LV_SESSION

    HOLDDATE = '20080121'

    KEEP = 'X'

    USER = SY-UNAME

    PROG = SY-CPROG

    • IMPORTING

    • QID =

    EXCEPTIONS

    CLIENT_INVALID = 1

    DESTINATION_INVALID = 2

    GROUP_INVALID = 3

    GROUP_IS_LOCKED = 4

    HOLDDATE_INVALID = 5

    INTERNAL_ERROR = 6

    QUEUE_ERROR = 7

    RUNNING = 8

    SYSTEM_LOCK_ERROR = 9

    USER_INVALID = 10

    OTHERS = 11

    .

    IF SY-SUBRC <> 0.

    MESSAGE E000(ZHNC) WITH 'SESSION NOT OPENED'.

    ENDIF.

    ENDFORM. " F_OPEN_SESSION

    &----


    *& Form F_BDC_INSERT

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM F_BDC_INSERT .

    CALL FUNCTION 'BDC_INSERT'

    EXPORTING

    TCODE = 'XD01'

    TABLES

    DYNPROTAB = IT_bdcdata

    EXCEPTIONS

    INTERNAL_ERROR = 1

    NOT_OPEN = 2

    QUEUE_ERROR = 3

    TCODE_INVALID = 4

    PRINTING_INVALID = 5

    POSTING_INVALID = 6

    OTHERS = 7

    .

    IF SY-SUBRC <> 0.

    MESSAGE E000(ZHNC) WITH 'UNABLE TO INSERT'.

    ENDIF.

    ENDFORM. " F_BDC_INSERT

    &----


    *& Form F_FORMAT_MESSAGE

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM F_FORMAT_MESSAGE .

    DATA:LV_MSG(255).

    CALL FUNCTION 'FORMAT_MESSAGE'

    EXPORTING

    ID = SY-MSGID

    LANG = '-D'

    NO = SY-MSGNO

    V1 = SY-MSGV1

    V2 = SY-MSGV2

    V3 = SY-MSGV3

    V4 = SY-MSGV4

    IMPORTING

    MSG = LV_MSG

    EXCEPTIONS

    NOT_FOUND = 1

    OTHERS = 2

    .

    IF SY-SUBRC = 0.

    WRITE: / LV_MSG.

    ENDIF.

    ENDFORM. " F_FORMAT_MESSAGE

    &----


    *& Form F_CLOSE_SESSION

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM F_CLOSE_SESSION .

    CALL FUNCTION 'BDC_CLOSE_GROUP'

    EXCEPTIONS

    NOT_OPEN = 1

    QUEUE_ERROR = 2

    OTHERS = 3

    .

    IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    ENDFORM. " F_CLOSE_SESSION

    &----


    *& Form F_WRITE_TOP

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM F_WRITE_TOP .

    WRITE: / 'TOTAL NO OF RECORDS PROCESSED =', V_TLINES,

    'TOTAL NO OF ERROR RECORDS PROCESSED =', V_ELINES,

    'TOTAL NO OF SUCESS RECORDS PROCESSED =', V_SLINES,

    'NAME OF THE SESSION',V_SESS.

    ENDFORM. " F_WRITE_TOP

    Add a comment
    10|10000 characters needed characters exceeded

    Assigned Tags

    Related questions

    1 Answer

    • author's profile photo Former Member
      Former Member
      Posted on Jan 22, 2008 at 10:16 AM

      Screens in background do behave differently. To find the error you can simulate background mode while running the BDC session in foreground.

      Choose "foreground processing" and mark the flag "simulate background mode" with an 'X'. In this way you will see the exact screen sequence as it is in background.

      Add a comment
      10|10000 characters needed characters exceeded

    Before answering

    You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
    You must be Logged in to submit an answer.

    Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.