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 FOR CO02

Former Member
0 Likes
3,182

Hi

I am doing BDC for CO02.I need to assign Serial numbers manually to the production order.Mine is table control BDC. after entering 19 Records in the table control.My values are not getting from 20th record.even after SHDB recording.

My SHDB recording is not taking cursor recording and the cursor is not going after 19 records. even aftr fist time i enter all the values manually.

can any one have inputs for this to get cursor from 20th record

Regards

Rasheed

1 ACCEPTED SOLUTION
Read only

former_member376453
Contributor
0 Likes
2,183

Hi As far as I know, for table control, if 20th record is not in your current screen then you need to press a page down that is P+ function code. Please try this in your BDC

Kuntal

Hi

I am doing BDC for CO02.I need to assign Serial numbers manually to the production order.Mine is table control BDC. after entering 19 Records in the table control.My values are not getting from 20th record.even after SHDB recording.

My SHDB recording is not taking cursor recording and the cursor is not going after 19 records. even aftr fist time i enter all the values manually.

can any one have inputs for this to get cursor from 20th record

Regards

Rasheed

6 REPLIES 6
Read only

Former Member
0 Likes
2,183

This message was moderated.

Read only

former_member376453
Contributor
0 Likes
2,184

Hi As far as I know, for table control, if 20th record is not in your current screen then you need to press a page down that is P+ function code. Please try this in your BDC

Kuntal

Read only

former_member632729
Contributor
0 Likes
2,183

Hi Dude,

Creating production orders is one of common tasks when you have some external system that does the planning. Even if you work u201Cdirectlyu201D in R/3, you will probably need to create or change production orders. The SAPu2019s standard answer - BDC - is not really performant if you are processing a lot of data. To disappointment of any ABAPer, SAP provides no BAPIs to deal with that task (they do for order confirmations though). But fortunately, there are some other function modules that can help us. Before going further, I have to say that those functions can help you to create a production order, change its header parameters like scheduled start, or change its operations. Changing components, documents or production resources still has to be done with BDC (CO01 or CO02).

For production orders, SAP has implemented an interface for external planning systems (and even provided some documentation!). Their own u201Cexternalu201D system, APO, does not use those functions (actually, one function supporting different tasks), but they are kind of official and you can find some documents on them in SAP help. Of course, the use is not limited to external systems and the function can be used directly from ABAP programs.

So, letu2019s start with creating an order. The function that we are going to use is CLOI_CHANGES_UPL_31. Donu2019t get confused by the u201C31u2033 in its name. It works perfectly in 4.6 and (most likely) in later version of R/3. There is one inportant point that you have to keep in mind when working with the function: you are given just one call per session. That means, you can create one order or many orders, but with one call. After that, some internal state data is messed up and to save us from initializing it (which has to be done with some really internal functions), we better start a new sesion if we need to call the function again. So, in my example code below I am going to check whether the current session is not the last one allowed for the current user and call the function in a new task. Note that we have to do the check before EACH call unless we are really sure (I do it only once in the sample code below). Since itu2019s going to be an anynchronous call, we need to suspend our program until the function running in parallel finishes and get the return data into our program. This is achieved with standard SAP constructs like u201Cperforming u2026 on end of tasku201D in the CALL FUNCTION statement and u201Creceive resultsu201D in the form that is performed. I am also using a global variable that tells me that the call is over. You can find more useful information in SAP OSS note 545860 that described those specifics about calling that function.

Example



* 1. Create a production order.

data: t_cloi_ord_exp          type standard table of cloiord,
      lw_cloi_ord_exp         type cloiord,
      lt_cloi_msg_obj_log_exp type standard table of cloimoblog,
      lt_cloi_methods_exp     type standard table of cloimetlog,
      t_cloi_messages_exp     type standard table of cloimsglog,
      lw_cloi_messages_exp    type cloimsglog,
      ls_cloi_if_par_v2       like cloiifpar.

data:     lt_cloi_ordu        type standard table of cloiordu,
          lw_cloi_ordu        type cloiordu,
          lt_cloi_ordi        type standard table of cloiordi,
          lw_cloi_ordi        type cloiordi,
          lt_cloi_ord_opru    type standard table of CLOIOPERU,
          lw_cloi_ord_opru    type CLOIOPERU.

data:
  lf_date   like sy-datum,
  lf_date2  like sy-datum,
  f_flag(1) type c,
  f_aufnr   like aufk-aufnr.

data: f_act_sess like sm04dic-counter,
      f_max_sess like sm04dic-counter.

lf_date = sy-datum + 7.   "let's try to schedule it next week
lf_date2 = sy-datum + 14.

clear: ls_cloi_if_par_v2.

* those fields below are described in SAP help, but nevermind...
ls_cloi_if_par_v2-commitflg   = 'C'.
ls_cloi_if_par_v2-r3_version  = '40'.
ls_cloi_if_par_v2-metlog_req  = 'X'.
ls_cloi_if_par_v2-msglog_req  = 'X'.
ls_cloi_if_par_v2-msgobj_req  = 'X'.
ls_cloi_if_par_v2-ord_req     = 'X'.
ls_cloi_if_par_v2-ordseq_req  = 'X'.
ls_cloi_if_par_v2-ordopr_req  = 'X'.

* in case if we have external number range,
* we have to provide the future order number
lw_cloi_ordi-extaufnr = '1234567890'.

* material
lw_cloi_ordi-field =  'MATNR'.
lw_cloi_ordi-value =  'MATNUM1'.
append lw_cloi_ordi to lt_cloi_ordi.

* plant
lw_cloi_ordi-field =  'WERKS'.
lw_cloi_ordi-value = 'W001'.
append lw_cloi_ordi to lt_cloi_ordi.

* order type
lw_cloi_ordi-field =  'AUART'.
lw_cloi_ordi-value = 'PP01'.
append lw_cloi_ordi to lt_cloi_ordi.

* quantity
lw_cloi_ordi-field =  'BDMNG'.
lw_cloi_ordi-value = '100'.
append lw_cloi_ordi to lt_cloi_ordi.

lw_cloi_ordi-field =  'GLTRP'.    "finish date
lw_cloi_ordi-value = lf_date2.
append lw_cloi_ordi to lt_cloi_ordi.

lw_cloi_ordi-field =  'GSTRP'.    "start date
lw_cloi_ordi-value = lf_date.
append lw_cloi_ordi to lt_cloi_ordi.

* now check if we have one free session
call function 'TH_USER_INFO'
     importing
          act_sessions = f_act_sess
          max_sessions = f_max_sess
     exceptions
          others       = 1.

if sy-subrc  0 or f_act_sess >= f_max_sess.
  message e208(00) with 'No more free sessions'.
endif.

* and finally, let it happen!
clear: f_flag.
call function 'CLOI_CHANGES_UPL_31'
     starting new task 'CLOI_TEST'
     performing receive_res on end of task
     exporting
          cloi_if_par          = ls_cloi_if_par_v2
     tables
          cloi_ordi_imp        = lt_cloi_ordi
          cloi_method_log_exp  = lt_cloi_methods_exp
          cloi_message_log_exp = t_cloi_messages_exp
          cloi_msg_obj_log_exp = lt_cloi_msg_obj_log_exp
          cloi_ord_exp         = t_cloi_ord_exp.

* wait till the global variable will be set by our form
wait until f_flag = 'X'.
This is the form that is used to receive results and signalize
the end of processing:

form receive_res using taskname.

  data: lt_cloi_msg_obj_log_exp type standard table of cloimoblog,
        lt_cloi_methods_exp     type standard table of cloimetlog.

  receive results from function 'CLOI_CHANGES_UPL_31'
     tables
       cloi_method_log_exp        = lt_cloi_methods_exp
       cloi_message_log_exp       = t_cloi_messages_exp
       cloi_msg_obj_log_exp       = lt_cloi_msg_obj_log_exp
       cloi_ord_exp               = t_cloi_ord_exp.

  f_flag = 'X'.

endform.
The list of created production orders is returned back in the global table t_cloi_ord_exp. Now, letu2019s release them. (Setting, for example, technically complete status is similar). We are going to use the parameter cloi_ordu_imp instead of cloi_ordi_imp (I for insert, U for update). We populate the field FIELD with the value u201CMETHODu201D to say that we are not setting any values but we want to call a u201Cmethodu201D of releasing the order (method in the same sense as in object programming).

* release created prod order

clear: lt_cloi_ordu.
loop at t_cloi_ord_exp into lw_cloi_ord_exp.
  check not lw_cloi_ord_exp-aufnr is initial.
  clear: lw_cloi_ordu.
  lw_cloi_ordu-aufnr  =  lw_cloi_ord_exp-aufnr.
  f_aufnr  =  lw_cloi_ord_exp-aufnr.
*   Methods:
*     SetTechnicalComplete
*     RevokeTechnicalCompletion
*     Schedule
*     Release
*     SetUserStatus
*     RevokeUserStatus
  lw_cloi_ordu-field  =  'METHOD'.
  lw_cloi_ordu-value  =  'Release'.
  append lw_cloi_ordu to lt_cloi_ordu.
endloop.

clear: lt_cloi_methods_exp, t_cloi_messages_exp,
       lt_cloi_msg_obj_log_exp, t_cloi_ord_exp.

clear: f_flag.
call function 'CLOI_CHANGES_UPL_31'
     starting new task 'CLOI_TEST'
     performing receive_res on end of task
     exporting
          cloi_if_par          = ls_cloi_if_par_v2
     tables
          cloi_ordu_imp        = lt_cloi_ordu
          cloi_method_log_exp  = lt_cloi_methods_exp
          cloi_message_log_exp = t_cloi_messages_exp
          cloi_msg_obj_log_exp = lt_cloi_msg_obj_log_exp
          cloi_ord_exp         = t_cloi_ord_exp.

wait until f_flag = 'X'.
Now, as the order is created and released, letu2019s do some simple change. We are going to change the workcenter of the orderu2019s operation.

* change the work center of the operation 0010

clear: lt_cloi_ord_opru.
clear: lw_cloi_ord_opru.
lw_cloi_ord_opru-aufnr  =  f_aufnr.
lw_cloi_ord_opru-aplfl  =  0.
lw_cloi_ord_opru-vornr  =  '0010'.
lw_cloi_ord_opru-field  =  'ARBID'.
* note that this is the internal ID of workcenter!
lw_cloi_ord_opru-value  =  '10000001'.
append lw_cloi_ord_opru to lt_cloi_ord_opru.

clear: lt_cloi_methods_exp, t_cloi_messages_exp,
       lt_cloi_msg_obj_log_exp, t_cloi_ord_exp.

clear: f_flag.
call function 'CLOI_CHANGES_UPL_31'
     starting new task 'CLOI_TEST'
     performing receive_res on end of task
     exporting
          cloi_if_par          = ls_cloi_if_par_v2
     tables
          cloi_ord_opru_imp    = lt_cloi_ord_opru
          cloi_method_log_exp  = lt_cloi_methods_exp
          cloi_message_log_exp = t_cloi_messages_exp
          cloi_msg_obj_log_exp = lt_cloi_msg_obj_log_exp
          cloi_ord_exp         = t_cloi_ord_exp.

wait until f_flag = 'X'.
Thatu2019s it! The function that we use doesnu2019t let us do anything we may need, but it can be very useful anyways. Itu2019s stable and u201Cblessedu201D by SAP, and I have seen it used in third-party products that need to be integrated with SAP. If you have any doubts, or your supervisor does, donu2019t forget to point to the SAP help documentation. Itu2019s a small reassurance that itu2019s not one of those u201Cinternal onlyu201D functions that are better to avoid. And, the main point will of course be the performance if compared with BDC.

Read only

Former Member
0 Likes
2,183

hi rasheed u should be bit tricky in this scenerio as when u move from 20 th postion in table or list it again come to 1st postion and so on..see following code it might help you..

in this example i have 12 records in screen and after 12 records i m intializing again to 1

perform bdc_screen using 'SAPMM07I' '0721' 'X'.

i = 1.

loop at itab_stock.

concatenate 'ISEG-MATNR(' i ')' into fnam.

perform bdc_field using fnam itab_stock-matnr.

if i = '12'.

perform bdc_field using 'BDC_OKCODE' '/00'.

perform bdc_screen using 'SAPMM07I' '0721' 'X'.

i = 0.

endif.

i = i + 1.

endloop.

Read only

Former Member
0 Likes
2,183

Hi rashid,

Check this link.A similar issue is resolved here.Check the CALL TRANSACTION statement carefully.

https://wiki.sdn.sap.com/wiki/x/DQGqAw

Luck,

Bhumika

Read only

Former Member
0 Likes
2,183

Hi,

Thanks for all your inputs.

I resolved Myself.

Regards

Rasheed