Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

BDC

Hi ,

The following is my BDC pgm.It works in Foreground but not in Background.

The tcode is IW32.The requirement is to update the basic start date in the maintainence order.

Thanks.

REPORT YMPM_UPDATE_ORDER_START_DATE .

TABLES: SSCRFIELDS.

DATA: BEGIN OF ITAB OCCURS 0,

AUFNR LIKE AFKO-AUFNR,

AUART LIKE AUFK-AUART,

OBSTD(10),

OBSTT LIKE AFKO-GSUZP,

GSTRP(10),

GSUZP(5),

AUTERM LIKE AFKO-NAUTERM,

END OF ITAB.

DATA : ERROR(13).

DATA : V_DATE(10).

DATA: BEGIN OF ITAB2 OCCURS 0,

AUFNR LIKE AFKO-AUFNR,

OBSTD(10),

GSTRP(10),

ETEXT(40),

END OF ITAB2.

DATA: BEGIN OF WA1,

TXT04 LIKE TJ02T-TXT04,

END OF WA1.

DATA: BEGIN OF WA2,

GSTRP LIKE AFKO-GSTRP,

GLTRP LIKE AFKO-GLTRP,

END OF WA2.

DATA: OBSTD(10),

OBFDAT(10).

DATA: I_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

DATA: I_BDCDATA2 LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

DATA: I_EXCEL LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.

PARAMETERS: V_FILE LIKE RLGRAP-FILENAME .

SELECTION-SCREEN PUSHBUTTON 79(12) BUTT USER-COMMAND BROWSE.

PARAMETERS : V_ERROR LIKE ERROR DEFAULT 'C:\ERROR.TXT'.

SELECTION-SCREEN END OF BLOCK B1.

INITIALIZATION.

MOVE 'Browse..' TO BUTT.

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

IF SCREEN-NAME = 'V_ERROR'.

SCREEN-INPUT = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

AT SELECTION-SCREEN.

IF SSCRFIELDS-UCOMM EQ 'BROWSE'.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

FIELD_NAME = ' '

IMPORTING

FILE_NAME = V_FILE .

ENDIF.

IF V_FILE = ' '.

MESSAGE 'File not found.' TYPE 'E'.

ENDIF.

START-OF-SELECTION.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

FILENAME = V_FILE

I_BEGIN_COL = '1'

I_BEGIN_ROW = '1'

I_END_COL = '6' "CHANGE

I_END_ROW = '5' "CHANGE

TABLES

INTERN = I_EXCEL

EXCEPTIONS

INCONSISTENT_PARAMETERS = 1

UPLOAD_OLE = 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.

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

LOOP AT I_EXCEL.

CASE I_EXCEL-COL.

WHEN '0001'.

ITAB-AUFNR = I_EXCEL-VALUE.

WHEN '0002'.

ITAB-AUART = I_EXCEL-VALUE.

WHEN '0003'.

ITAB-OBSTD = I_EXCEL-VALUE.

WHEN '0004'.

ITAB-OBSTT = I_EXCEL-VALUE.

WHEN '0005'.

ITAB-GSTRP = I_EXCEL-VALUE.

WHEN '0006'.

ITAB-GSUZP = I_EXCEL-VALUE.

ENDCASE.

IF I_EXCEL-COL = 6.

APPEND ITAB.

CLEAR ITAB.

ENDIF.

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

ENDLOOP.

LOOP AT ITAB.

REFRESH I_BDCDATA.

CLEAR I_BDCDATA.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = ITAB-AUFNR

IMPORTING

OUTPUT = ITAB-AUFNR

.

SELECT SINGLE GSTRP

GLTRP

FROM AFKO

INTO WA2

WHERE AUFNR = ITAB-AUFNR.

  • SELECT C~TXT04 INTO WA1 FROM

  • TJ02T AS C INNER JOIN JEST AS B

  • ON CISTAT = BSTAT

  • INNER JOIN AUFK AS A

  • ON AOBJNR EQ BOBJNR

  • WHERE B~STAT = 'I0001'

  • AND A~AUFNR = ITAB-AUFNR

  • AND C~SPRAS = 'E'.

*

*ENDSELECT.

DATA : BEGIN OF IT_JEST OCCURS 0,

STAT LIKE JEST-STAT,

END OF IT_JEST.

SELECT B~STAT INTO TABLE IT_JEST FROM JEST AS B

INNER JOIN

AUFK AS A

ON AOBJNR = BOBJNR

WHERE A~AUFNR = ITAB-AUFNR.

READ TABLE IT_JEST WITH KEY STAT = 'I0002'.

IF SY-SUBRC = 0.

WA1-TXT04 = 'REL'.

ELSE .

WA1-TXT04 = 'CRTD'.

ENDIF.

CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'

EXPORTING

DATE_INTERNAL = WA2-GSTRP

IMPORTING

DATE_EXTERNAL = OBSTD

EXCEPTIONS

DATE_INTERNAL_IS_INVALID = 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.

CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'

EXPORTING

DATE_INTERNAL = WA2-GLTRP

IMPORTING

DATE_EXTERNAL = OBFDAT

EXCEPTIONS

DATE_INTERNAL_IS_INVALID = 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.

IF WA1-TXT04 <> 'CRTD'.

ITAB2-AUFNR = ITAB-AUFNR.

ITAB2-OBSTD = ITAB-OBSTD.

ITAB2-GSTRP = ITAB-GSTRP.

ITAB2-ETEXT = 'System Status is not CRTD'.

APPEND ITAB2.

CLEAR ITAB2.

continue.

ENDIF.

IF OBSTD <> ITAB-OBSTD.

ITAB2-AUFNR = ITAB-AUFNR.

ITAB2-OBSTD = ITAB-OBSTD.

ITAB2-GSTRP = ITAB-GSTRP.

ITAB2-ETEXT = 'Basic Start Dates are unequal'.

APPEND ITAB2.

CLEAR ITAB2.

ENDIF.

LOOP AT ITAB2.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = 'C:/ERROR.TXT'

FILETYPE = 'ASC'

  • APPEND = ' '

WRITE_FIELD_SEPARATOR = 'X'

  • HEADER = '00'

  • TRUNC_TRAILING_BLANKS = ' '

  • WRITE_LF = 'X'

  • COL_SELECT = ' '

  • COL_SELECT_MASK = ' '

  • DAT_MODE = ' '

  • CONFIRM_OVERWRITE = ' '

  • NO_AUTH_CHECK = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • WRITE_BOM = ' '

  • TRUNC_TRAILING_BLANKS_EOL = 'X'

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = ITAB2

  • FIELDNAMES =

  • EXCEPTIONS

  • FILE_WRITE_ERROR = 1

  • NO_BATCH = 2

  • GUI_REFUSE_FILETRANSFER = 3

  • INVALID_TYPE = 4

  • NO_AUTHORITY = 5

  • UNKNOWN_ERROR = 6

  • HEADER_NOT_ALLOWED = 7

  • SEPARATOR_NOT_ALLOWED = 8

  • FILESIZE_NOT_ALLOWED = 9

  • HEADER_TOO_LONG = 10

  • DP_ERROR_CREATE = 11

  • DP_ERROR_SEND = 12

  • DP_ERROR_WRITE = 13

  • UNKNOWN_DP_ERROR = 14

  • ACCESS_DENIED = 15

  • DP_OUT_OF_MEMORY = 16

  • DISK_FULL = 17

  • DP_TIMEOUT = 18

  • FILE_NOT_FOUND = 19

  • DATAPROVIDER_EXCEPTION = 20

  • CONTROL_FLUSH_ERROR = 21

  • OTHERS = 22

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

ENDLOOP.

IF ( OBSTD = ITAB-OBSTD ).

PERFORM BDC_SCREEN USING 'SAPLCOIH' '0101'.

PERFORM BDC_FIELD USING 'CAUFVD-AUFNR' ITAB-AUFNR.

PERFORM BDC_FIELD USING 'BDC_OKCODE' '/00'.

PERFORM BDC_SCREEN USING 'SAPLCOIH' '3000'.

PERFORM BDC_FIELD USING 'CAUFVD-GSTRP' ITAB-GSTRP.

IF ( OBFDAT < ITAB-GSTRP ).

PERFORM BDC_FIELD USING 'CAUFVD-GLTRP' ITAB-GSTRP.

ENDIF.

PERFORM BDC_FIELD USING 'CAUFVD-GSUZP' ITAB-GSUZP.

PERFORM BDC_FIELD USING 'CAUFVD-AUTERM' ' ' .

PERFORM BDC_FIELD USING 'BDC_OKCODE' 'BU'.

PERFORM BDC_SCREEN USING 'SAPLZPM_ROADS' '2000'.

  • PERFORM BDC_CURSOR USING GS_YVM_ODOMETER-CNTRC

perform bdc_field using 'BDC_CURSOR'

'GS_YVM_ODOMETER-CNTRC'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' 'EXIT'.

PERFORM BDC_SCREEN USING 'SAPLSPO1' '0500'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' '/00'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' 'OPT1'.

CALL TRANSACTION 'IW32'

USING I_BDCDATA

MODE 'N'.

ENDIF.

ENDLOOP.

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

I_BDCDATA2-PROGRAM = 'YMPM_BUS_CAPACITY_SYNC'. "PROGRAM NAME

I_BDCDATA2-DYNPRO = '1000'. "SCREEN NUMBER

I_BDCDATA2-DYNBEGIN = 'X'.

APPEND I_BDCDATA2.

CLEAR I_BDCDATA2.

PERFORM BDC_FIELD2 USING 'S_IWERK-LOW' 'WBUS'.

*PERFORM BDC_FIELD2 USING 'S_INGPR-LOW' 'AMK'.

PERFORM BDC_FIELD2 USING 'S_AUART-LOW' 'RPM1'.

*PERFORM BDC_FIELD2 USING 'S_ILART-LOW' 'PMA'.

CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'

EXPORTING

DATE_INTERNAL = SY-DATUM

IMPORTING

DATE_EXTERNAL = V_DATE

EXCEPTIONS

DATE_INTERNAL_IS_INVALID = 1

OTHERS = 2.

PERFORM BDC_FIELD2 USING 'S_GSTRP-LOW' V_DATE.

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

CALL TRANSACTION 'YVM315' USING I_BDCDATA2

MODE 'A'.

&----


*& Form BDC_SCREEN

&----


  • text

----


  • -->P_0174 text

  • -->P_0175 text

----


FORM BDC_SCREEN USING P_PROGRAM P_DYNPRO.

I_BDCDATA-PROGRAM = P_PROGRAM.

I_BDCDATA-DYNPRO = P_DYNPRO.

I_BDCDATA-DYNBEGIN = 'X'.

APPEND I_BDCDATA.

CLEAR I_BDCDATA.

ENDFORM. " BDC_SCREEN

&----


*& Form BDC_FIELD

&----


  • text

----


  • -->P_0179 text

  • -->P_ITAB_AUFNR text

----


FORM BDC_FIELD USING P_FNAM P_FVAL.

I_BDCDATA-FNAM = P_FNAM.

I_BDCDATA-FVAL = P_FVAL.

APPEND I_BDCDATA.

CLEAR I_BDCDATA.

ENDFORM. " BDC_FIELD

&----


*& Form BDC_FIELD2

&----


  • text

----


  • -->P_0268 text

  • -->P_0269 text

----


FORM BDC_FIELD2 USING P_FNAM P_FVAL.

I_BDCDATA2-FNAM = P_FNAM.

I_BDCDATA2-FVAL = P_FVAL.

APPEND I_BDCDATA2.

CLEAR I_BDCDATA2.

ENDFORM. " BDC_FIELD2

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question