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

Issue with BDC program

Former Member
0 Likes
952

Hi,

When I do BDC recording for custom transaction YAFIE01 and when I run in SHDB it is updating the equipment but when I convert the same recording into BDC program and when I run that program its not updating.

steps are given below.

1. Enter Tcode YAFIE01

2.select " MODIFY" radiabutton

3.Give values for Equipment and Plant and click ENTER

3.Click on EXECUTE

4.Select YES option in the POP UP window for updating.

INPUT DATA:

EQUNR : 10720953

WERKS: 1050

Expected Result: Measuring Points copied from plant related equipment to 10720953. Plant and Equipment data is maintained in Ytable- YAFT_REFEQUI.

Below is the program i am getting after converting the recording

include bdcrecx1.

start-of-selection.

perform open_group.

perform bdc_dynpro using 'SAPLYAFF_EQUI_CREATE' '9000'.

perform bdc_field using 'BDC_CURSOR'

'W_RADIO2'.

perform bdc_field using 'BDC_OKCODE'

'=W_RAD'.

perform bdc_field using 'W_RADIO1'

''.

perform bdc_field using 'W_RADIO2'

'X'.

perform bdc_dynpro using 'SAPLYAFF_EQUI_CREATE' '9000'.

perform bdc_field using 'BDC_CURSOR'

'W_WERKS1'.

perform bdc_field using 'BDC_OKCODE'

'=ENTER'.

perform bdc_field using 'W_RADIO2'

'X'.

perform bdc_field using 'W_EQUNR'

'10720953'.

perform bdc_field using 'W_WERKS1'

'1050'.

perform bdc_dynpro using 'SAPLYAFF_EQUI_CREATE' '9000'.

perform bdc_field using 'BDC_CURSOR'

'W_MATNR1'.

perform bdc_field using 'BDC_OKCODE'

'=EXECUTE'.

perform bdc_field using 'W_RADIO2'

'X'.

perform bdc_field using 'W_MATNR1'

'2612511-2'.

perform bdc_field using 'W_SERNR1'

'IW15'.

perform bdc_field using 'W_EQUNR'

'10720953'.

perform bdc_field using 'W_WERKS1'

'1050'.

perform bdc_dynpro using 'SAPLSPO1' '0500'.

perform bdc_field using 'BDC_OKCODE'

'=OPT1'.

perform bdc_dynpro using 'SAPLYAFF_EQUI_CREATE' '9000'.

perform bdc_dynpro using 'SAPLYAFF_EQUI_CREATE' '9000'.

perform bdc_field using 'BDC_OKCODE'

'/EBACK'.

perform bdc_field using 'BDC_CURSOR'

'W_MATNR1'.

perform close_group.

But this is not working..

pls help in doing this.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
874

dear parasuram ,

while doing recording just after your 4 th step , save the data in recording only .

one more perform will be created sumthing like

perform bdc_field using 'BDC_OKCODE'

'/BU'.

REGARDS

ranjan

7 REPLIES 7
Read only

Former Member
0 Likes
875

dear parasuram ,

while doing recording just after your 4 th step , save the data in recording only .

one more perform will be created sumthing like

perform bdc_field using 'BDC_OKCODE'

'/BU'.

REGARDS

ranjan

Read only

Former Member
0 Likes
874

hii,

you are also missing the FM 'gui_upload' or 'ws_upload' just after start of selection

regards

Ranjan

Read only

Former Member
0 Likes
874

data : begin of itab  occurs 0 ,
EQUNR type equnr ,
WERKS  type  works ,
end of itab .

DATA:   bdcdata LIKE bdcdata    OCCURS 0 WITH HEADER LINE.
*       messages of call transaction
DATA:   messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
*       error session opened (' ' or 'X')
DATA:   e_group_opened.



SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS : p_fname LIKE rlgrap-filename OBLIGATORY.
*               P_START LIKE SY-TABIX DEFAULT 1 OBLIGATORY.
PARAMETERS   ctu_mode  LIKE ctu_params-dismode DEFAULT 'A'.

SELECTION-SCREEN END OF BLOCK b2.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname.
  CALL FUNCTION 'F4_FILENAME'
    EXPORTING
      program_name  = syst-cprog
      dynpro_number = syst-dynnr
    IMPORTING
      file_name     = p_fname.

start-of-selection.
CALL FUNCTION 'GUI_UPLOAD'
 EXPORTING

   filename                      =  p_fname
   filetype                      = 'DAT'
  TABLES
    data_tab                      = itab
 EXCEPTIONS
   conversion_error              = 1
   file_open_error               = 2
   file_read_error               = 3
   invalid_type                  = 4
   no_batch                      = 5
   unknown_error                 = 6
   invalid_table_width           = 7
   gui_refuse_filetransfer       = 8
   customer_error                = 9
   no_authority                  = 10
   OTHERS                        = 11
          .
****perform open_group.

loop at itab .

perform bdc_dynpro using 'SAPLYAFF_EQUI_CREATE' '9000'.
perform bdc_field using 'BDC_CURSOR'
'W_RADIO2'.
perform bdc_field using 'BDC_OKCODE'
'=W_RAD'.
perform bdc_field using 'W_RADIO1'
''.
perform bdc_field using 'W_RADIO2'
'X'.

perform bdc_dynpro using 'SAPLYAFF_EQUI_CREATE' '9000'.
perform bdc_field using 'BDC_CURSOR'
'W_WERKS1'.
perform bdc_field using 'BDC_OKCODE'
'=ENTER'.
perform bdc_field using 'W_RADIO2'
'X'.
perform bdc_field using 'W_EQUNR'
'10720953'.
perform bdc_field using 'W_WERKS1'
'1050'.

perform bdc_dynpro using 'SAPLYAFF_EQUI_CREATE' '9000'.
perform bdc_field using 'BDC_CURSOR'
'W_MATNR1'.
perform bdc_field using 'BDC_OKCODE'
'=EXECUTE'.
perform bdc_field using 'W_RADIO2'
'X'.
perform bdc_field using 'W_MATNR1'
'2612511-2'.
perform bdc_field using 'W_SERNR1'
'IW15'.
perform bdc_field using 'W_EQUNR'
'10720953'.
perform bdc_field using 'W_WERKS1'
'1050'.

perform bdc_dynpro using 'SAPLSPO1' '0500'.
perform bdc_field using 'BDC_OKCODE'
'=OPT1'.

perform bdc_dynpro using 'SAPLYAFF_EQUI_CREATE' '9000'.
perform bdc_dynpro using 'SAPLYAFF_EQUI_CREATE' '9000'.
perform bdc_field using 'BDC_OKCODE'
'/EBACK'.
perform bdc_field using 'BDC_CURSOR'
'W_MATNR1'.
 CALL TRANSACTION 'YAFIE01' USING bdcdata MODE ctu_mode UPDATE 'S'.

  REFRESH bdcdata.
  CLEAR: bdcdata, itab.

ENDLOOP.

FORM bdc_dynpro USING program dynpro.
  CLEAR bdcdata.
  bdcdata-program  = program.
  bdcdata-dynpro   = dynpro.
  bdcdata-dynbegin = 'X'.
  APPEND bdcdata.
ENDFORM.                    "BDC_DYNPRO

*----------------------------------------------------------------------*
*        Insert field                                                  *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
*  IF FVAL <> NODATA.
  CLEAR bdcdata.
  bdcdata-fnam = fnam.
  bdcdata-fval = fval.
  SHIFT bdcdata-fval LEFT DELETING LEADING space.
  APPEND bdcdata.
*  ENDIF.
ENDFORM.                    "BDC_FIELD


*&---------------------------------------------------------------------*
*&      Form  BDC_FIELD_wrbtr
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->FNAM       text
*      -->FVAL       text
*----------------------------------------------------------------------*

FORM bdc_field_aktiv USING fnam fval .
  DATA : char(15).
  char = fval.
  CLEAR bdcdata.
  bdcdata-fnam = fnam.
  bdcdata-fval = char.
  APPEND bdcdata.
ENDFORM.            

Read only

0 Likes
874

both the subroutines

1. bdc_field ,

2, bdc_field_aktiv

use the same parameters fnam , fval ... try changing the parameters of the 2nd subroutine to fnam2 , fval2 .. i also faced such an issue , hope this resolves yur problem .. !! ..

FORM bdc_field_aktiv USING fnam2 fval2

also clear all the params fnam , fnam2 , fval , fval2 just before endforms,

Read only

0 Likes
874

Hi Ranjan,

Thankful for your code however it still couldn't solve my problem.So I hope we shlould look for any other alternative solution.

Thanks,

Parasuram

Read only

0 Likes
874

Are you able to see your session and able to process. If so, process in foreground and check if you are getting any errors.

Read only

0 Likes
874

I could create sessions and when i process the session there are no errors. Session was processed successfully but the data is not updated. Anyhow I finished this requirement by cloning the program of tcode YAFID01. So whenever we are free we need to look this issue get resolved and put it in the thread. Till then keep this thread open.

Thanks for your reply...

Parasuram