Skip to Content
0
Former Member
Sep 10, 2009 at 10:31 AM

Error in BDC for Infotype 0589

20 Views

Hi friends,

I have developed a BDC program for Infotype 0589. After executing the program to upload data from file, I am getting error message: Field Q0589-ANZHL(7) input value is longer than screen field

Here I am adding my Sample code also.

REPORT ZTEST_0589.

PARAMETERS :

p_file TYPE rlgrap-filename. " Accepts File Name

*" Type declarations...................................................

TYPES :

BEGIN OF type_s_it0589,

pernr TYPE rp50g-pernr, " Personnel Number

inftyp TYPE rp50g-choic, " Infotype

begda TYPE p0589-begda, " Begin Date

endda TYPE p0589-endda, " End Date

lga01 TYPE q0589-lgart,

betrg01 TYPE q0589-betrg,

anzhl01 TYPE q0589-anzhl,

lga02 TYPE q0589-lgart,

betrg02 TYPE q0589-betrg,

anzhl02 TYPE q0589-anzhl,

lga03 TYPE q0589-lgart,

betrg03 TYPE q0589-betrg,

anzhl03 TYPE q0589-anzhl,

lga04 TYPE q0589-lgart,

betrg04 TYPE q0589-betrg,

anzhl04 TYPE q0589-anzhl,

lga05 TYPE q0589-lgart,

betrg05 TYPE q0589-betrg,

anzhl05 TYPE q0589-anzhl,

lga06 TYPE q0589-lgart,

betrg06 TYPE q0589-betrg,

anzhl06 TYPE q0589-anzhl,

lga07 TYPE q0589-lgart,

betrg07 TYPE q0589-betrg,

anzhl07 TYPE q0589-anzhl,

lga08 TYPE q0589-lgart,

betrg08 TYPE q0589-betrg,

anzhl08 TYPE q0589-anzhl,

END OF type_s_it0589.

  • Work variables

"----


DATA:

w_file TYPE string, " File Name

w_betrg(50) TYPE c, " Proposed Contribution

w_anzhl(50) TYPE c, " Actual Contribution

w_count(2) TYPE n, " Counter

w_year(4) TYPE n, " Year

w_month(2) TYPE n, " Month

w_day(2) TYPE n, " Day

w_date(10) TYPE c, " Date

w_wage(50) TYPE c, " wage

w_waget(50) TYPE c, " wage type

w_curr(12) TYPE c, " Currency

w_tabrows LIKE sy-srows VALUE 7, " Table Control rows

w_update TYPE i, " Number of Updated Records

w_failed TYPE i, " Number of Failed Records

w_0589_lines TYPE i, " Number of Records in File

w_text TYPE string. " CheckBox for considering

" Actual Contributions

"----


  • Structure to hold File Data *

"----


DATA :

fs_it0589 TYPE type_s_it0589.

"----


  • Structure to hold Batch input: New table field structure *

"----


DATA :

fs_bdcdata TYPE bdcdata.

"----


  • Structure to hold Messages in the SAP System *

"----


DATA :

fs_messages TYPE bdcmsgcoll.

"----


  • Structure to hold Personnel Number, Message Type & Message Text *

"----


DATA:

BEGIN OF fs_log,

pernr TYPE rp50g-pernr,

msgtxt(200) TYPE c,

msgtyp TYPE c,

END OF fs_log.

"----


  • Structure to hold Parameter string for runtime of CALL TRANSACTION *

"----


DATA :

fs_opt TYPE ctu_params.

"----


  • Internal Table to hold File Data *

"----


DATA :

t_it0589 LIKE

STANDARD TABLE

OF fs_it0589.

"----


  • Internal Table to hold Batch input: New table field structure *

"----


DATA :

t_bdcdata TYPE

STANDARD TABLE

OF bdcdata.

"----


  • Internal Table to hold Messages in the SAP System *

"----


DATA:

t_messages TYPE TABLE OF bdcmsgcoll.

"----


  • Internal Table to hold Personnel Number, Message Type & Message Text*

"----


DATA:

t_log LIKE

STANDARD TABLE

OF fs_log.

FORM validate .

IF p_file IS INITIAL.

MESSAGE e005(zvalid).

ENDIF. " IF P_FILE IS INITIAL.

MOVE p_file TO w_file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = w_file

filetype = 'ASC'

has_field_separator = 'X'

dat_mode = 'X'

TABLES

data_tab = t_it0589

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 NE 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

IF t_it0589 IS INITIAL.

MESSAGE e006(zvalid).

ENDIF. " IF T_IT0589 IS INITIAL

ENDFORM. " FORM VALIDATE

FORM f4_help .

CALL FUNCTION 'F4_FILENAME'

IMPORTING

file_name = p_file.

ENDFORM. " FORM F4_HELP

&----


*& Form FILL_BDCDATA

&----


FORM fill_bdcdata .

DESCRIBE TABLE t_it0589 LINES w_0589_lines.

LOOP AT t_it0589 INTO fs_it0589.

REFRESH t_bdcdata.

REFRESH t_messages.

PERFORM bdc_dynpro USING 'SAPMP50A' '1000'.

PERFORM bdc_field USING 'RP50G-PERNR'

fs_it0589-pernr.

w_year = fs_it0589-begda+0(4).

w_month = fs_it0589-begda+4(2).

w_day = fs_it0589-begda+6(2).

CONCATENATE w_day w_month w_year INTO w_date

SEPARATED BY '.'.

PERFORM bdc_field USING 'RP50G-BEGDA'

w_date.

w_year = fs_it0589-endda+0(4).

w_month = fs_it0589-endda+4(2).

w_day = fs_it0589-endda+6(2).

CONCATENATE w_day w_month w_year INTO w_date

SEPARATED BY '.'.

PERFORM bdc_field USING 'RP50G-ENDDA'

w_date.

PERFORM bdc_field USING 'RP50G-CHOIC'

fs_it0589-inftyp.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_dynpro USING 'SAPMP50A' '1000'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=INS'.

PERFORM bdc_dynpro USING 'MP058900' '2000'.

  • 1st Row...............................................................

ADD 1 TO w_count.

MOVE fs_it0589-lga01 TO w_wage.

PERFORM bdc_field USING 'Q0589-LGART(01)'

w_wage.

MOVE fs_it0589-betrg01 TO w_curr.

PERFORM bdc_field USING 'Q0589-BETRG(01)'

w_curr.

MOVE fs_it0589-anzhl01 TO w_curr.

PERFORM bdc_field USING 'Q0589-ANZHL(01)'

w_curr.

  • 2nd Row...............................................................

  • 3rd Row...............................................................

  • 4th Row...............................................................

  • 5th Row...............................................................

  • 6th Row...............................................................

ADD 1 TO w_count.

IF w_count > w_tabrows .

w_count = 1.

PERFORM bdc_field USING 'BDC_OKCODE'

'P+' .

PERFORM bdc_dynpro USING 'MP058900' '2000'.

ENDIF. " IF W_COUNT > W_TABROWS

MOVE fs_it0589-lga06 TO w_curr.

CONCATENATE 'Q0589-LGART(' w_count ')' INTO w_wage.

PERFORM bdc_field USING w_wage

w_curr.

MOVE fs_it0589-betrg06 TO w_curr.

CONCATENATE 'Q0589-BETRG(' w_count ')' INTO w_betrg.

PERFORM bdc_field USING w_betrg

w_curr.

MOVE fs_it0589-anzhl06 TO w_curr.

CONCATENATE 'Q0589-ANZHL(' w_count ')' INTO w_anzhl.

PERFORM bdc_field USING w_anzhl

w_curr.

  • 7th Row...............................................................

ADD 1 TO w_count.

IF w_count > w_tabrows .

w_count = 1.

PERFORM bdc_field USING 'BDC_OKCODE'

'P+' .

PERFORM bdc_dynpro USING 'MP058900' '2000'.

ENDIF. " IF W_COUNT > W_TABROWS

MOVE fs_it0589-lga07 TO w_curr.

CONCATENATE 'Q0589-LGART(' w_count ')' INTO w_wage.

PERFORM bdc_field USING w_wage

w_curr.

MOVE fs_it0589-betrg07 TO w_curr.

CONCATENATE 'Q0589-BETRG(' w_count ')' INTO w_betrg.

PERFORM bdc_field USING w_betrg

w_curr.

MOVE fs_it0589-anzhl07 TO w_curr.

CONCATENATE 'Q0589-ANZHL(' w_count ')' INTO w_anzhl.

PERFORM bdc_field USING w_anzhl

w_curr.

!

*- -- Same upto 15 rows.......

  • Save..................................................................

PERFORM bdc_field USING 'BDC_OKCODE'

'=UPD'.

  • Back..................................................................

PERFORM bdc_dynpro USING 'MP058900' '2000'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/EBCK'.

w_count = 0.

CALL TRANSACTION 'PA30' USING t_bdcdata

OPTIONS FROM fs_opt

MESSAGES INTO t_messages.

LOOP AT t_messages INTO fs_messages.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

id = fs_messages-msgid

lang = sy-langu

no = fs_messages-msgnr

v1 = fs_messages-msgv1

v2 = fs_messages-msgv2

v3 = fs_messages-msgv3

v4 = fs_messages-msgv4

IMPORTING

msg = fs_log-msgtxt

EXCEPTIONS

not_found = 1

OTHERS = 2.

IF sy-subrc NE 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF. " IF SY-SUBRC NE 0

MOVE fs_it0589-pernr TO fs_log-pernr.

MOVE fs_messages-msgtyp TO fs_log-msgtyp.

APPEND fs_log TO t_log.

CLEAR fs_log.

IF fs_messages-msgtyp EQ 'S'

AND fs_messages-msgnr EQ '102'.

ADD 1 TO w_update.

ELSEIF fs_messages-msgtyp EQ 'S'

AND fs_messages-msgnr EQ '015'

OR fs_messages-msgtyp EQ 'E'.

ADD 1 TO w_failed.

ENDIF. " IF FS_MESSAGES-MSGTYP EQ 'S'

ENDLOOP. " LOOP AT T_MESSAGES

ENDLOOP. " LOOP AT T_IT0585

WRITE :/ 'Number of Records Fetched from file'(001),

50 w_0589_lines COLOR 1,

/ 'Number of Records Updated into the database'(002),

50 w_update COLOR 1,

/ 'Number of Records Failed to update into database'(003),

50 w_failed COLOR 6 .

SKIP 3.

WRITE :/ 'Detailed Log.....'(004).

SKIP 1.

LOOP AT t_log INTO fs_log.

AT NEW pernr.

WRITE :/ fs_log-pernr COLOR 1.

ENDAT. " AT NEW PERNR

IF fs_log-msgtyp = 'E'.

WRITE :15 fs_log-msgtxt COLOR 6 INVERSE ON.

ELSE.

WRITE :15 fs_log-msgtxt.

ENDIF. " IF FS_LOG-MSGTYP = 'E'

ENDLOOP. " LOOP AT T_LOG INTO FS_LOG

ENDFORM. " FORM FILL_BDCDATA

&----


*& Form BDC_DYNPRO

&----


  • This subroutine starts new screen *

----


  • There are no interface parameters to be passed to this subroutine. *

----


FORM bdc_dynpro USING program dynpro.

CLEAR fs_bdcdata.

fs_bdcdata-program = program.

fs_bdcdata-dynpro = dynpro.

fs_bdcdata-dynbegin = 'X'.

APPEND fs_bdcdata TO t_bdcdata.

ENDFORM. " FORM BDC_DYNPRO

&----


*& Form BDC_FIELD

&----


  • This subroutine inserts field *

----


  • There are no interface parameters to be passed to this subroutine. *

----


FORM bdc_field USING fnam fval.

CLEAR fs_bdcdata.

fs_bdcdata-fnam = fnam.

fs_bdcdata-fval = fval.

APPEND fs_bdcdata TO t_bdcdata.

ENDFORM. " FORM BDC_FIELD

Thanks,

Ziad khan