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 Program using CALL Transaction not working in SM36

Former Member
0 Likes
2,246

Hi Experts,

Kindly help me out.

I have created a BDC program using CALL Transaction method. But while trying to schedlue the same program in background as a peridoic job using SM36 then data not getting populated.

Thanks..

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,601

Pl expert help me out..

 

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

* BDC Program For PDI Out Date Update Based on IMIS

* Date : 2013.07.04

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

 

Report ZBDC_SD no standard page heading line-size 255.

 

 

* Internal Table Declaration

*DATA : T_BDCDATA TYPE TABLE OF BDCDATA.

 

DATA: Begin of t_bdcdata occurs 0.

include structure bdcdata.

DATA: End of t_bdcdata.

 

*Data decleration for Error Message

 

DATA:Begin of t_msg occurs 0.

Include structure bdcmsgcoll.

DATA:End of t_msg.

DATA:

w_msg TYPE bdcmsgcoll,

w_msg1(51).

Data: opt type ctu_params.

DATA : P_IFRESULT(1) TYPE C,

P_IFFAILMSG(300) TYPE C.

DATA : BEGIN OF IT_8950 OCCURS 0.

INCLUDE STRUCTURE ZHINSDT8950.

DATA : END OF IT_8950.

DATA : BEGIN OF IT_4360 OCCURS 0.

INCLUDE STRUCTURE ZHINSDT4360.

DATA : END OF IT_4360.

 

* Data declaration

 

DATA : WA_8950 LIKE IT_8950.

DATA : LV_TDATE(10) TYPE C,

LV_FDATE(10) TYPE C,

LV_PDATE TYPE SY-DATUM,

LV_CAR(10) TYPE C.

DATA: FS_BDCDATA LIKE LINE OF T_BDCDATA. " Structure type of bdcdata

TYPES : BEGIN OF ty_s_error,

msg_err(60) TYPE c,

END OF ty_s_error.

DATA:

wa_path TYPE string ,

wa_error TYPE string,

wa_cnt TYPE i,

w_mode TYPE c,

wa_cnt1(2) TYPE n,

it_output type table of ty_s_error,

wa_output like line of it_output.

 

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

* *START-OF-SELECTION.

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

 

START-OF-SELECTION.

SELECT * FROM ZHINSDT8950

INTO CORRESPONDING FIELDS OF TABLE IT_8950

WHERE ZCIFSTAT = 'I'.

LOOP AT IT_8950 INTO WA_8950.

REFRESH: T_BDCDATA.

CLEAR FS_BDCDATA.

PERFORM POPULATE_BDCDATA.

PERFORM INSERT_DATA.

CLEAR: WA_8950,t_bdcdata, t_bdcdata[],t_msg,t_msg[].

ENDLOOP.

END-OF-SELECTION.

 

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

 

FORM POPULATE_BDCDATA.

CLEAR LV_CAR.

CONCATENATE WA_8950-ZCMODL WA_8950-ZSSERIAL INTO LV_CAR SEPARATED BY SPACE.

WRITE SY-DATUM TO LV_TDATE.

CALL FUNCTION 'CCM_GO_BACK_MONTHS'

EXPORTING

CURRDATE = SY-DATUM

BACKMONTHS = '001'

IMPORTING

NEWDATE = LV_PDATE.

WRITE LV_PDATE TO LV_FDATE.

 

PERFORM:

FILL_BDC_DATA USING 'ZHINSDR50200B' '1000' 'X' ' ' ' ',

FILL_BDC_DATA USING ' ' ' ' ' ' 'BDC_OKCODE' '=ONLI',

FILL_BDC_DATA USING ' ' ' ' ' ' 'S_BODY-LOW' LV_CAR,

FILL_BDC_DATA USING ' ' ' ' ' ' 'S_PROD-LOW' LV_FDATE,

FILL_BDC_DATA USING ' ' ' ' ' ' 'S_PROD-HIGH' LV_TDATE,

FILL_BDC_DATA USING 'ZHINSDR50200B' '0100' 'X' ' ' ' ',

FILL_BDC_DATA USING ' ' ' ' ' ' 'BDC_OKCODE' '=APPR'.

ENDFORM. "End Of Populate Data

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

FORM FILL_BDC_DATA USING VALUE(P_PROGRAM)

VALUE(P_DYNPRO)

VALUE(P_DYNBEGIN)

VALUE(P_FNAM)

VALUE(P_FVAL).

CLEAR FS_BDCDATA.

IF P_DYNBEGIN = 'X' .

FS_BDCDATA-PROGRAM = P_PROGRAM .

FS_BDCDATA-DYNPRO = P_DYNPRO .

FS_BDCDATA-DYNBEGIN = P_DYNBEGIN .

APPEND FS_BDCDATA TO T_BDCDATA.

ELSE.

FS_BDCDATA-FNAM = P_FNAM.

FS_BDCDATA-FVAL = P_FVAL.

CONDENSE FS_BDCDATA-FVAL.

APPEND FS_BDCDATA TO T_BDCDATA.

ENDIF.

ENDFORM . " End of Populate Data

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

* Insert Data

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

FORM INSERT_DATA.

opt-dismode = 'N'.

opt-updmode = 'S'.

opt-racommit = 'X'.

OPT-NOBINPT = 'X'.

CALL TRANSACTION 'ZHINSDR50200B' USING t_bdcdata

OPTIONS FROM opt

MESSAGES INTO t_msg.

READ TABLE t_msg WITH KEY msgtyp = 'S' msgnr = '010'.

IF sy-subrc EQ 0.

WA_8950-ZCIFSTAT = 'Z'. WA_8950-ZERTNMG = 'SUCCESS'.

MOVE-CORRESPONDING WA_8950 to IT_8950.

MODIFY ZHINSDT8950 FROM IT_8950.

COMMIT WORK.

ELSE.

LOOP AT t_msg INTO w_msg WHERE msgtyp EQ 'E'.

CALL FUNCTION 'MESSAGE_TEXT_BUILD'

EXPORTING

msgid = w_msg-msgid

msgnr = w_msg-msgnr

msgv1 = w_msg-msgv1

msgv2 = w_msg-msgv2

msgv3 = w_msg-msgv3

msgv4 = w_msg-msgv4

IMPORTING

message_text_output = w_msg1.

wa_output-msg_err = w_msg1.

WA_8950-ZCIFSTAT = 'E'.

WA_8950-ZERTNMG = wa_output-msg_err.

MOVE-CORRESPONDING WA_8950 to IT_8950.

MODIFY ZHINSDT8950 FROM IT_8950.

COMMIT WORK.

ENDLOOP.

ENDIF.

ENDFORM.

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

Hi Experts,

Kindly help me out.

I have created a BDC program using CALL Transaction method. But while trying to schedlue the same program in background as a peridoic job using SM36 then data not getting populated.

Thanks..

10 REPLIES 10
Read only

FredericGirod
Active Contributor
0 Likes
1,601

Hi Arthi,

You have create a program, this program make a CALL Transaction to create a Batch-Input ...  

Do you mean Call Transaction using BDCDATA or a Call Transaction that create a Batch-Input ??

When you run your job in back ground, did you have a log ? an error in the job ? an error in the SM35 ? ST22 ? SM21 ? 

Witch transaction did you try to call ?

regards

Fred

Read only

0 Likes
1,601

This message was moderated.

Read only

venkateswaran_k
Active Contributor
0 Likes
1,601

Hi Arthi,

How are you reading the data for the BDC?   Do you use any GUI function to read the file?

Please note that GUI functions will not work in Background?

Can you please let me know how the data is read and fed into BDC?

Regards,

Venkat

Read only

Former Member
0 Likes
1,601

Hi Arthi,

Have you mentioned in CALL Transaction the mode of processing.

It should be in 'N' that is for background.

Please refer SAP Help for details

http://help.sap.com/saphelp_40b/helpdata/EN/fa/09715a543b11d1898e0000e8322d00/content.htm

Regards

Read only

Former Member
0 Likes
1,601

Hi Arthi,

CALL TRANSACTION WILL NOT WORK PROPERLY  IN BACKGROUND MODE, TRY TO USE  CALL SESSTION  METHOD PROCESS

-GANESH

Read only

Former Member
0 Likes
1,602

Pl expert help me out..

 

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

* BDC Program For PDI Out Date Update Based on IMIS

* Date : 2013.07.04

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

 

Report ZBDC_SD no standard page heading line-size 255.

 

 

* Internal Table Declaration

*DATA : T_BDCDATA TYPE TABLE OF BDCDATA.

 

DATA: Begin of t_bdcdata occurs 0.

include structure bdcdata.

DATA: End of t_bdcdata.

 

*Data decleration for Error Message

 

DATA:Begin of t_msg occurs 0.

Include structure bdcmsgcoll.

DATA:End of t_msg.

DATA:

w_msg TYPE bdcmsgcoll,

w_msg1(51).

Data: opt type ctu_params.

DATA : P_IFRESULT(1) TYPE C,

P_IFFAILMSG(300) TYPE C.

DATA : BEGIN OF IT_8950 OCCURS 0.

INCLUDE STRUCTURE ZHINSDT8950.

DATA : END OF IT_8950.

DATA : BEGIN OF IT_4360 OCCURS 0.

INCLUDE STRUCTURE ZHINSDT4360.

DATA : END OF IT_4360.

 

* Data declaration

 

DATA : WA_8950 LIKE IT_8950.

DATA : LV_TDATE(10) TYPE C,

LV_FDATE(10) TYPE C,

LV_PDATE TYPE SY-DATUM,

LV_CAR(10) TYPE C.

DATA: FS_BDCDATA LIKE LINE OF T_BDCDATA. " Structure type of bdcdata

TYPES : BEGIN OF ty_s_error,

msg_err(60) TYPE c,

END OF ty_s_error.

DATA:

wa_path TYPE string ,

wa_error TYPE string,

wa_cnt TYPE i,

w_mode TYPE c,

wa_cnt1(2) TYPE n,

it_output type table of ty_s_error,

wa_output like line of it_output.

 

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

* *START-OF-SELECTION.

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

 

START-OF-SELECTION.

SELECT * FROM ZHINSDT8950

INTO CORRESPONDING FIELDS OF TABLE IT_8950

WHERE ZCIFSTAT = 'I'.

LOOP AT IT_8950 INTO WA_8950.

REFRESH: T_BDCDATA.

CLEAR FS_BDCDATA.

PERFORM POPULATE_BDCDATA.

PERFORM INSERT_DATA.

CLEAR: WA_8950,t_bdcdata, t_bdcdata[],t_msg,t_msg[].

ENDLOOP.

END-OF-SELECTION.

 

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

 

FORM POPULATE_BDCDATA.

CLEAR LV_CAR.

CONCATENATE WA_8950-ZCMODL WA_8950-ZSSERIAL INTO LV_CAR SEPARATED BY SPACE.

WRITE SY-DATUM TO LV_TDATE.

CALL FUNCTION 'CCM_GO_BACK_MONTHS'

EXPORTING

CURRDATE = SY-DATUM

BACKMONTHS = '001'

IMPORTING

NEWDATE = LV_PDATE.

WRITE LV_PDATE TO LV_FDATE.

 

PERFORM:

FILL_BDC_DATA USING 'ZHINSDR50200B' '1000' 'X' ' ' ' ',

FILL_BDC_DATA USING ' ' ' ' ' ' 'BDC_OKCODE' '=ONLI',

FILL_BDC_DATA USING ' ' ' ' ' ' 'S_BODY-LOW' LV_CAR,

FILL_BDC_DATA USING ' ' ' ' ' ' 'S_PROD-LOW' LV_FDATE,

FILL_BDC_DATA USING ' ' ' ' ' ' 'S_PROD-HIGH' LV_TDATE,

FILL_BDC_DATA USING 'ZHINSDR50200B' '0100' 'X' ' ' ' ',

FILL_BDC_DATA USING ' ' ' ' ' ' 'BDC_OKCODE' '=APPR'.

ENDFORM. "End Of Populate Data

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

FORM FILL_BDC_DATA USING VALUE(P_PROGRAM)

VALUE(P_DYNPRO)

VALUE(P_DYNBEGIN)

VALUE(P_FNAM)

VALUE(P_FVAL).

CLEAR FS_BDCDATA.

IF P_DYNBEGIN = 'X' .

FS_BDCDATA-PROGRAM = P_PROGRAM .

FS_BDCDATA-DYNPRO = P_DYNPRO .

FS_BDCDATA-DYNBEGIN = P_DYNBEGIN .

APPEND FS_BDCDATA TO T_BDCDATA.

ELSE.

FS_BDCDATA-FNAM = P_FNAM.

FS_BDCDATA-FVAL = P_FVAL.

CONDENSE FS_BDCDATA-FVAL.

APPEND FS_BDCDATA TO T_BDCDATA.

ENDIF.

ENDFORM . " End of Populate Data

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

* Insert Data

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

FORM INSERT_DATA.

opt-dismode = 'N'.

opt-updmode = 'S'.

opt-racommit = 'X'.

OPT-NOBINPT = 'X'.

CALL TRANSACTION 'ZHINSDR50200B' USING t_bdcdata

OPTIONS FROM opt

MESSAGES INTO t_msg.

READ TABLE t_msg WITH KEY msgtyp = 'S' msgnr = '010'.

IF sy-subrc EQ 0.

WA_8950-ZCIFSTAT = 'Z'. WA_8950-ZERTNMG = 'SUCCESS'.

MOVE-CORRESPONDING WA_8950 to IT_8950.

MODIFY ZHINSDT8950 FROM IT_8950.

COMMIT WORK.

ELSE.

LOOP AT t_msg INTO w_msg WHERE msgtyp EQ 'E'.

CALL FUNCTION 'MESSAGE_TEXT_BUILD'

EXPORTING

msgid = w_msg-msgid

msgnr = w_msg-msgnr

msgv1 = w_msg-msgv1

msgv2 = w_msg-msgv2

msgv3 = w_msg-msgv3

msgv4 = w_msg-msgv4

IMPORTING

message_text_output = w_msg1.

wa_output-msg_err = w_msg1.

WA_8950-ZCIFSTAT = 'E'.

WA_8950-ZERTNMG = wa_output-msg_err.

MOVE-CORRESPONDING WA_8950 to IT_8950.

MODIFY ZHINSDT8950 FROM IT_8950.

COMMIT WORK.

ENDLOOP.

ENDIF.

ENDFORM.

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

Read only

0 Likes
1,601

Hi Arthi,

You are calling a Z Transaction.... Check first if it works in normal run properly that is in FOREGROUND

I mentioned above use MODE 'N' if you don't specify it will try to run in fore ground only.

CALL TRANSACTION 'ZHINSDR50200B' USING t_bdcdata MODE 'N'

OPTIONS FROM opt

MESSAGES INTO t_msg.

Regards

Read only

venkateswaran_k
Active Contributor
0 Likes
1,601

Hi Arthi,

1.  Is this program works fine when you execute it in foreground?

2.  ZHINSDR50200B  -  can you share the code of this program?  ( just to clarify is this a tcode or program id   🙂 )

Please update

Read only

Former Member
0 Likes
1,601

Thank You..

Issue solved.

Read only

0 Likes
1,601

Hi Arthi,

Can you please update the thread as what was the issue.  This will help others who is looking for similar problem

Regards,

Venkat