Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

problem while creating customer BDC

Former Member
0 Likes
1,376

Hi Experts,

I am coming across an error customer already exits, how to clear created customer from the screen (xd01)  for the next record of my flat file ,

while screen processing as it get the previous created customer gets by default.

as my file contain customer numbers which need to create.

thanks in advance...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,335

Thanks for all,

now its working fine,

I need to refresh the bdc data..

Thanks again..

11 REPLIES 11
Read only

Former Member
0 Likes
1,335

Use SET PARAMETER. I think it is 'KUN' for customer.

Regards,

Shravan

Read only

0 Likes
1,335

Hi Shravan

Thanks for the Reply..

i had tried that one but still it is not working.

the Customer value remains the same for next record of the file.

Regards,

Hpy

Read only

Clemenss
Active Contributor
0 Likes
1,335

Hpy,

your BDC can set a blank value to the field.

Regards

Clemens

Read only

Former Member
0 Likes
1,335

Hi Clemens,

Thanks for reply..

But my main intention is to pass the value as it has been given in the flat file and that numbers customers only need to be created.

is there is any approach to do so without getting the customer number by default on the screen for second record of the file.

Regards,

Hpy

Read only

Former Member
0 Likes
1,335

HI

you can maintain select distanct here we can avoid the duplicate records

or free keyword there you can distinct distinct the repeated one

Read only

0 Likes
1,335

Hi raman,

the problem is not respect to duplicate records in the file in fact there is no duplicate records in the file

it is with respect to sap memory as the first record is created it remains for the second record also due to sap memory.

please check the report..

*&---------------------------------------------------------------------*

*& Report  ZOO_BDC

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

REPORT  ZOO_BDC.

  *---------------------------------------------------------------------*

*       CLASS LCL_BDC_CLASS DEFINITION

*---------------------------------------------------------------------*

*

*---------------------------------------------------------------------*

CLASS LCL_BDC_CLASS DEFINITION.

  PUBLIC SECTION.

    METHODS : FILE_BDC IMPORTING IM_FILE TYPE STRING

                       CHANGING IM_IT_DATA TYPE STANDARD TABLE,

              FILL_SCREEN IMPORTING IM_PROGRAM TYPE BDC_PROG

                                    IM_DYNPRO TYPE BDC_DYNR

                                    IM_DYNBEGIN TYPE BDC_START,

              FILL_FIELDS IMPORTING IM_FNAM TYPE FNAM_____4

                                    IM_FVAL TYPE C.

  PROTECTED SECTION.

    DATA : IT_BDCDATA TYPE TABLE OF BDCDATA,

           WA_BDCDATA TYPE BDCDATA.

ENDCLASS.                    "LCL_BDC_CLASS DEFINITION

*---------------------------------------------------------------------*

*       CLASS LCL_BDC_CLASS IMPLEMENTATION

*---------------------------------------------------------------------*

*

*---------------------------------------------------------------------*

CLASS LCL_BDC_CLASS IMPLEMENTATION.

  METHOD FILE_BDC.

    CALL FUNCTION 'GUI_UPLOAD'

      EXPORTING

        FILENAME                      = IM_FILE

       FILETYPE                      = 'ASC'

       HAS_FIELD_SEPARATOR           = 'X'

*   HEADER_LENGTH                 = 0

*   READ_BY_LINE                  = 'X'

*   DAT_MODE                      = ' '

*   CODEPAGE                      = ' '

*   IGNORE_CERR                   = ABAP_TRUE

*   REPLACEMENT                   = '#'

*   CHECK_BOM                     = ' '

*   VIRUS_SCAN_PROFILE            =

* IMPORTING

*   FILELENGTH                    =

*   HEADER                        =

      TABLES

        DATA_TAB                      = IM_IT_DATA

* EXCEPTIONS

*   FILE_OPEN_ERROR               = 1

*   FILE_READ_ERROR               = 2

*   NO_BATCH                      = 3

*   GUI_REFUSE_FILETRANSFER       = 4

*   INVALID_TYPE                  = 5

*   NO_AUTHORITY                  = 6

*   UNKNOWN_ERROR                 = 7

*   BAD_DATA_FORMAT               = 8

*   HEADER_NOT_ALLOWED            = 9

*   SEPARATOR_NOT_ALLOWED         = 10

*   HEADER_TOO_LONG               = 11

*   UNKNOWN_DP_ERROR              = 12

*   ACCESS_DENIED                 = 13

*   DP_OUT_OF_MEMORY              = 14

*   DISK_FULL                     = 15

*   DP_TIMEOUT                    = 16

*   OTHERS                        = 17

              .

    IF SY-SUBRC <> 0.

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

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

    ENDIF.

  ENDMETHOD.                    "FILE_BDC

  METHOD FILL_SCREEN.

    CLEAR WA_BDCDATA.

    WA_BDCDATA-PROGRAM = IM_PROGRAM.

    WA_BDCDATA-DYNPRO = IM_DYNPRO.

    WA_BDCDATA-DYNBEGIN = IM_DYNBEGIN.

    APPEND WA_BDCDATA TO IT_BDCDATA.

  ENDMETHOD.                    "FILL_SCREEN

  METHOD FILL_FIELDS.

    CLEAR WA_BDCDATA.

    WA_BDCDATA-FNAM = IM_FNAM.

    WA_BDCDATA-FVAL = IM_FVAL.

    APPEND WA_BDCDATA TO IT_BDCDATA.

  ENDMETHOD.                    "FILL_FIELDS

ENDCLASS.                    "LCL_BDC_CLASS IMPLEMENTATION

*---------------------------------------------------------------------*

*       CLASS LCL_BDC_CALL_TRANS DEFINITION

*---------------------------------------------------------------------*

*

*---------------------------------------------------------------------*

CLASS LCL_BDC_CALL_TRANS DEFINITION INHERITING FROM LCL_BDC_CLASS.

  PUBLIC SECTION.

    METHODS CALL_TRANSCATION IMPORTING IM_TCODE TYPE C

                                       IM_UPDATE TYPE C

                                       IM_MODE TYPE C.

ENDCLASS.                    "LCL_BDC_CALL_TRANS DEFINITION

*---------------------------------------------------------------------*

*       CLASS LCL_BDC_CALL_TRANS IMPLEMENTATION

*---------------------------------------------------------------------*

*

*---------------------------------------------------------------------*

CLASS LCL_BDC_CALL_TRANS IMPLEMENTATION.

  METHOD CALL_TRANSCATION.

    CALL TRANSACTION IM_TCODE USING IT_BDCDATA UPDATE IM_UPDATE MODE IM_MODE.

  ENDMETHOD.                    "CALL_TRANSCATION

ENDCLASS.                    "LCL_BDC_CALL_TRANS IMPLEMENTATION

*---------------------------------------------------------------------*

*                DECLERATION

*---------------------------------------------------------------------*

TYPES : BEGIN OF TY_KNA1,

        KUNNR TYPE KNA1-KUNNR,

        KTOKD TYPE KNA1-KTOKD,

        NAME1 TYPE KNA1-NAME1,

        SORTL TYPE KNA1-SORTL,

        STRAS TYPE KNA1-STRAS,

        ORT01 TYPE KNA1-ORT01,

        PSTLZ TYPE KNA1-PSTLZ,

        LAND1 TYPE KNA1-LAND1,

        SPRAS TYPE KNA1-SPRAS,

      END OF TY_KNA1.

DATA : IT_KNA1 TYPE TABLE OF TY_KNA1,

       WA_KNA1 TYPE TY_KNA1.

DATA : OBJECT1 TYPE REF TO LCL_BDC_CALL_TRANS.

*---------------------------------------------------------------------*

*                START-OF-SELECTION

*---------------------------------------------------------------------*

START-OF-SELECTION.

  CREATE OBJECT OBJECT1.

  CALL METHOD OBJECT1->FILE_BDC

    EXPORTING

      IM_FILE    = 'C:\Documents and Settings\miracle\Desktop\FILE.TXT'

    CHANGING

      IM_IT_DATA = IT_KNA1.

  LOOP AT IT_KNA1 INTO WA_KNA1.

       CALL METHOD OBJECT1->FILL_SCREEN

      EXPORTING

        IM_PROGRAM  = 'SAPMF02D'

        IM_DYNPRO   = '0100'

        IM_DYNBEGIN = 'X'.

    CALL METHOD OBJECT1->FILL_FIELDS

      EXPORTING

        IM_FNAM = 'BDC_OKCODE'

        IM_FVAL = '/00'.

    CALL METHOD OBJECT1->FILL_FIELDS

      EXPORTING

        IM_FNAM = 'RF02D-KUNNR'

        IM_FVAL = WA_KNA1-KUNNR.

    CALL METHOD OBJECT1->FILL_FIELDS

      EXPORTING

        IM_FNAM = 'RF02D-KTOKD'

        IM_FVAL = WA_KNA1-KTOKD.

    CALL METHOD OBJECT1->FILL_SCREEN

      EXPORTING

        IM_PROGRAM  = 'SAPMF02D'

        IM_DYNPRO   = '0110'

        IM_DYNBEGIN = 'X'.

    CALL METHOD OBJECT1->FILL_FIELDS

      EXPORTING

        IM_FNAM = 'BDC_OKCODE'

        IM_FVAL = '=UPDA'.

    CALL METHOD OBJECT1->FILL_FIELDS

      EXPORTING

        IM_FNAM = 'KNA1-KUNNR'

        IM_FVAL = WA_KNA1-KUNNR.

    CALL METHOD OBJECT1->FILL_FIELDS

      EXPORTING

        IM_FNAM = 'KNA1-SORTL'

        IM_FVAL = WA_KNA1-SORTL.

    CALL METHOD OBJECT1->FILL_FIELDS

      EXPORTING

        IM_FNAM = 'KNA1-LAND1'

        IM_FVAL = WA_KNA1-LAND1.

    CALL METHOD OBJECT1->FILL_FIELDS

      EXPORTING

        IM_FNAM = 'KNA1-NAME1'

        IM_FVAL = WA_KNA1-NAME1.

    CALL METHOD OBJECT1->FILL_FIELDS

      EXPORTING

        IM_FNAM = 'KNA1-SPRAS'

        IM_FVAL = WA_KNA1-SPRAS.

    CALL METHOD OBJECT1->FILL_FIELDS

      EXPORTING

        IM_FNAM = 'KNA1-STRAS'

        IM_FVAL = WA_KNA1-STRAS.

    CALL METHOD OBJECT1->FILL_FIELDS

      EXPORTING

        IM_FNAM = 'KNA1-ORT01'

        IM_FVAL = WA_KNA1-ORT01.

    CALL METHOD OBJECT1->FILL_FIELDS

      EXPORTING

        IM_FNAM = 'KNA1-PSTLZ'

        IM_FVAL = WA_KNA1-PSTLZ.

    SET PARAMETER ID 'KUN' FIELD WA_KNA1-KUNNR.

    BREAK-POINT.

*    FREE MEMORY ID 'KUN'.

    CALL METHOD OBJECT1->CALL_TRANSCATION

      EXPORTING

        IM_TCODE  = 'XD01'

        IM_UPDATE = 'A'

        IM_MODE   = 'A'.

       CLEAR WA_KNA1.

  ENDLOOP.

Read only

0 Likes
1,335

Hi,

according to your code you set the KUNNR as

        IM_FNAM = 'RF02D-KUNNR'

        IM_FVAL = WA_KNA1-KUNNR.

This would overwrite any values present in that field.

What screen field are you talking about?

Regards

Clemens

Read only

0 Likes
1,335

Hi Clemen,

Thanks for reply,

values are changing in the debugger but it is not impacting on the screen.

Regards.

Hpy..

Read only

0 Likes
1,335

Hi,

   Just before filling the First screen, Use SET PARAMETER ID.

  LOOP AT IT_KNA1 INTO WA_KNA1.

SET PARAMETER ID 'KUN' VALUE wa_kna1-kunnr.

       CALL METHOD OBJECT1->FILL_SCREEN

      EXPORTING

        IM_PROGRAM  = 'SAPMF02D'

        IM_DYNPRO   = '0100'

        IM_DYNBEGIN = 'X'.

    CALL METHOD OBJECT1->FILL_FIELDS

      EXPORTING

        IM_FNAM = 'BDC_OKCODE'

        IM_FVAL = '/00'.

.....

ENDLOOP.

Read only

0 Likes
1,335

Hi,

Thanks for reply..

the whole data of the second record is not impacting the screen .

its not with respect to the customer...

i am getting all the data into the internal table but the second record of the file is not impacting onto the screen.

Regards

Hpy..

Read only

Former Member
0 Likes
1,336

Thanks for all,

now its working fine,

I need to refresh the bdc data..

Thanks again..