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

bdc upload for tcode 'ko22'

koolspy_ultimate
Active Contributor
0 Likes
1,480

error while uploading the excell file . ( field bpdy-wert1(1) input value is longer than screen field)

Any one please help me out <removed by moderator>


report ZIORETD
       no standard page heading line-size 255.
CONSTANTS: c_begcol TYPE i VALUE 1,
            c_begrow TYPE i VALUE 2,
            c_endcol TYPE i VALUE 2,
            c_endrow TYPE i VALUE 2000.
* Types Declaration *
types: begin of TY_Ko22,
       AUFNR TYPE AUFNR,
       wert1 TYPE wert1,
       end of TY_ko22.
* Data Declarations *
DATA: it_bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE,
      XL_itab type alsmex_tabline occurs 0 with header line.
data : it_itab type standard table of ty_ko22,
      wa_itab type ty_ko22.
* Selection Screen *
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_file LIKE rlgrap-filename.
SELECTION-SCREEN: END OF BLOCK b1.
* At Selection Screen for File *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  perform f4_filename.
* Start-of-selection *
start-of-selection.
*Uploading the data from excel to internal table
  perform excel_upload.
*Uploading to SAP
  perform chek_data.
end-of-selection.
*& Form F4_FILENAME
* Find the file
FORM F4_FILENAME .
  CALL FUNCTION 'F4_FILENAME'
    IMPORTING
      FILE_NAME = p_file.
ENDFORM. " F4_FILENAME
*&---------------------------------------------------------------------*
*& Form CHEK_DATA
FORM CHEK_DATA .
  loop at it_itab into wa_itab.
*perform open_group.
perform bdc_dynpro      using 'SAPMKBUD' '0300'.
perform bdc_field       using 'BDC_CURSOR'
                              'CODIA-AUFNR'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
perform bdc_field       using 'CODIA-AUFNR'
                              WA_ITAB-AUFNR."'8515'.
perform bdc_dynpro      using 'SAPLKBPP' '0320'.
perform bdc_field       using 'BDC_CURSOR'
                              'BPDY-WERT1(01)'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
perform bdc_field       using 'BPDY-WERT1(01)'
                              wa_itab-wert1."'464646456'.
perform bdc_dynpro      using 'SAPLKBPP' '0320'.
perform bdc_field       using 'BDC_CURSOR'
                              'BPDY-WERT1(01)'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
perform bdc_dynpro      using 'SAPLKBPP' '0320'.
perform bdc_field       using 'BDC_CURSOR'
                              'BPDY-WERT1(01)'.
perform bdc_field       using 'BDC_OKCODE'
                              '=POST'.
CALL TRANSACTION 'KO22' USING IT_BDCDATA MODE 'E' UPDATE 'S'.
    refresh it_bdcdata.
  ENDLOOP.
ENDFORM. " CHEK_DATA
*&---------------------------------------------------------------------*
*& Form EXCEL_UPLOAD
FORM EXCEL_UPLOAD .
  CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
      FILENAME    = p_file
      I_BEGIN_COL = c_begcol
      I_BEGIN_ROW = c_begrow
      I_END_COL   = c_endcol
      I_END_ROW   = c_endrow
    TABLES
      INTERN      = xl_itab.
* EXCEPTIONS
* INCONSISTENT_PARAMETERS = 1
* UPLOAD_OLE = 2
* OTHERS = 3 .
  IF SY-SUBRC = 0.
* MESSAGE 'DATA UPLOADED SUCCESSFULLY' TYPE 'I'.
  ENDIF.
  loop at xl_itab.
    case xl_itab-col.
      when '1'.
        wa_itab-AUFNR = xl_itab-value.
      when '2'.
        wa_itab-wert1 = xl_itab-value.
    endcase.
    at end of row.
      append wa_itab to it_itab.
    endat.
  endloop.
ENDFORM.                    "EXCEL_UPLOAD
" EXCEL_UPLOAD *&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
FORM BDC_DYNPRO USING A B.
  clear it_bdcdata.
  it_bdcdata-PROGRAM = A.
  it_bdcdata-DYNPRO = B.
  it_bdcdata-DYNBEGIN = 'X'.
  APPEND it_bdcdata.
ENDFORM. " BDC_DYNPRO
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
FORM BDC_FIELD USING C D.
  clear it_bdcdata.
  it_bdcdata-FNAM = C.
  it_bdcdata-FVAL = D.
  APPEND it_bdcdata.
ENDFORM. " BDC_FIELD

Edited by: Thomas Zloch on Apr 18, 2011 6:35 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,261

Hi,

Define the wa_itab-wert1 as character type of lenght 17.

Regards,

Madhukar Shetty

8 REPLIES 8
Read only

Former Member
0 Likes
1,262

Hi,

Define the wa_itab-wert1 as character type of lenght 17.

Regards,

Madhukar Shetty

Read only

0 Likes
1,261

not working

Read only

0 Likes
1,261

i tried this but not working. (error message: input must be in the format ._.__.__.__~,__V )

report ZIORETD
       no standard page heading line-size 255.

CONSTANTS: c_begcol TYPE i VALUE 1,
            c_begrow TYPE i VALUE 2,
            c_endcol TYPE i VALUE 2,
            c_endrow TYPE i VALUE 2000.
types: begin of TY_Ko22,
       AUFNR TYPE AUFNR,
       wert1 TYPE wert1,
       end of TY_ko22.
DATA: it_bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE,
      XL_itab type alsmex_tabline occurs 0 with header line.

data : it_itab type table of ty_ko22,
      wa_itab type ty_ko22.

data: L_amount(17) type c.
l_amount = WA_itab-WERT1.
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_file LIKE rlgrap-filename.
SELECTION-SCREEN: END OF BLOCK b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  perform f4_filename.
start-of-selection.
*Uploading the data from excel to internal table
  perform excel_upload.
*Uploading to SAP
  perform chek_data.

end-of-selection.
FORM F4_FILENAME .
  CALL FUNCTION 'F4_FILENAME'
    IMPORTING
      FILE_NAME = p_file.
ENDFORM. " F4_FILENAME
FORM CHEK_DATA .
  loop at it_itab into wa_itab.
     l_amount = WA_itab-WERT1.
*perform open_group.
perform bdc_dynpro      using 'SAPMKBUD' '0300'.
perform bdc_field       using 'BDC_CURSOR'
                              'CODIA-AUFNR'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
perform bdc_field       using 'CODIA-AUFNR'
                              WA_ITAB-AUFNR."'8515'.
perform bdc_dynpro      using 'SAPLKBPP' '0320'.
perform bdc_field       using 'BDC_CURSOR'
                              'BPDY-WERT1(01)'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
perform bdc_field       using 'BPDY-WERT1(01)'
                              l_amount."'464646456'.
perform bdc_dynpro      using 'SAPLKBPP' '0320'.
perform bdc_field       using 'BDC_CURSOR'
                              'BPDY-WERT1(01)'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
perform bdc_dynpro      using 'SAPLKBPP' '0320'.
perform bdc_field       using 'BDC_CURSOR'
                              'BPDY-WERT1(01)'.
perform bdc_field       using 'BDC_OKCODE'
                              '=POST'.
CALL TRANSACTION 'KO22' USING IT_BDCDATA MODE 'A' UPDATE 'S'.
    refresh it_bdcdata.
  ENDLOOP.
ENDFORM. " CHEK_DATA

FORM EXCEL_UPLOAD .
  CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
      FILENAME    = p_file
      I_BEGIN_COL = c_begcol
      I_BEGIN_ROW = c_begrow
      I_END_COL   = c_endcol
      I_END_ROW   = c_endrow
    TABLES
      INTERN      = xl_itab.
* EXCEPTIONS
* INCONSISTENT_PARAMETERS = 1
* UPLOAD_OLE = 2
* OTHERS = 3 .
  IF SY-SUBRC = 0.
* MESSAGE 'DATA UPLOADED SUCCESSFULLY' TYPE 'I'.
  ENDIF.
  loop at xl_itab.
    case xl_itab-col.
      when '1'.
        wa_itab-AUFNR = xl_itab-value.
      when '2'.
        wa_itab-wert1 = xl_itab-value.
    endcase.
    at end of row.
      append wa_itab to it_itab.
    endat.
  endloop.
ENDFORM.                    "EXCEL_UPLOAD
" EXCEL_UPLOAD *
*& Form BDC_DYNPRO
FORM BDC_DYNPRO USING A B.
  clear it_bdcdata.
  it_bdcdata-PROGRAM = A.
  it_bdcdata-DYNPRO = B.
  it_bdcdata-DYNBEGIN = 'X'.
  APPEND it_bdcdata.
ENDFORM. " BDC_DYNPRO
FORM BDC_FIELD USING C D.
  clear it_bdcdata.
  it_bdcdata-FNAM = C.
  it_bdcdata-FVAL = D.
  APPEND it_bdcdata.
ENDFORM. " BDC_FIELD

Read only

0 Likes
1,261

Him,

Try the below syntax..

Check in the currency field Periods are allowed (Comma seperator is not allowed)

try the below code above bdc

Replace all Occuranaces of ',' in l_amount with space.

Condense l_amount.

Prabhudas

Read only

0 Likes
1,261

closed

Read only

0 Likes
1,261

Hi,

it the prabhu opinion is correct?

how u solved this issue?

Thanks

Ashutosh

Read only

0 Likes
1,261

Hi,

it the prabhu opinion is correct?

how u solved this issue?

Thanks

Ashutosh

Read only

0 Likes
1,261

in the loop add this code.


Replace all Occuranaces of ',' in l_amount with space.
Condense l_amount.