09-26-2007 5:06 AM
Dear All,
When I am trying to upload Routing data using CA01 in the Table Control scenario, then I am facing problem as my last 2 records are not getting uploaded from my Test file.
For example, I am having 47 records in my Test File and after setting Default size parameters (to avoid screen resolution problem)
I have 15 table control line items data per page. The Page down logic ('=P+') is working fine, but my below BDC code failed to take
the remainder last 2 records from the Test File.
Analysis: When I am running my Call Transaction bdc in foreground, then the 1st page down occurs after 15th record, 2nd page down occurs after 29th record( as in Table Control 1st pages 15th record is coming on the Top of 2nd page). 3rd page down occurs after 43rd record
(as 2nd pages 29th record is coming on the top of 3rd page). In the 4th Table Control Page 43rd record of previous page is coming on top, and then its taking 44th & 45th records from the Test File and then it is triggering SAVE (=BU). Thus, our last 2 records
(i.e. 46th, 47th record) are not getting uploaded in the routing screen from our Test File.
If anybody has encountered this scenario previously, please help me URGENTLY in fixing the bugs here. Its VERY, VERY URGENT
FYI. For others 45 successful records already uploaded, all the screen fields values are coming properly in the routing screen, and here there is no issue.
Thanks very much
Thanks & Regards
Sudipta Project Lead
Volvo Client Location
I am pasting my BDC source code below:
REPORT ZRT1_UPLOAD_CA01_F
NO STANDARD PAGE HEADING
LINE-SIZE 255.
************************************************************************
I N C L U D E S *
************************************************************************
Include for Data Declarations
INCLUDE zrout_top.
Include for Forms
INCLUDE zrout_form.
INCLUDE zrout_include_f_ca01.
----
*AT SELECTION-SCREEN ON VALUE-REQUEST FOR <field>
----
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
Attaching F4 help with filename
PERFORM F1001_GET_F4.
************************************************************************
S T A R T - O F - S E L E C T I O N *
************************************************************************
START-OF-SELECTION.
Perform to read the input file
PERFORM f_read_file.
Perform to fill the BDC data
PERFORM f_fill_bdctab.
************************************************************************
E N D - O F - S E L E C T I O N *
************************************************************************
END-OF-SELECTION.
FREE: i_bdcdata,
i_messtab,
i_record.
-
x----
&----
*& Include ZROUT_TOP *
&----
************************************************************************
D A T A B A S E T A B L E S *
************************************************************************
TABLES: t100. "Messages
************************************************************************
D A T A D E C L A R A T I O N S *
************************************************************************
T A B L E T Y P E S *****************************
For input data
TYPES: BEGIN OF ty_record,
matnr(18), "Material Number
werks(4), "Plant
verwe(3), "Usage
statu(3), "Status
arbpl(8), "Work Center
steus(4), "Control Key
ltxa1(40), "Description of Operation
bmsch(13), "Base Quantity
meinh(3), "Unit of Measure
vgw01(11), "Machine
vge01(3), "Unit of measure of activity
END OF ty_record.
I N T E R N A L T A B L E S ***********************
Internal Table for input file name
DATA: i_file_tab TYPE STANDARD TABLE OF sdokpath INITIAL SIZE 0.
Internal Table for BDC Data
DATA: i_bdcdata TYPE STANDARD TABLE OF bdcdata INITIAL SIZE 0.
Internal Table for BDC Messages
DATA: i_messtab TYPE STANDARD TABLE OF bdcmsgcoll INITIAL SIZE 0.
Internal Table for Input file
DATA: i_record TYPE STANDARD TABLE OF ty_record INITIAL SIZE 0.
W O R K A R E A S *************************
Work Area for input file name
DATA: wa_file_tab LIKE sdokpath.
Work Area for BDC Data
DATA: wa_bdcdata LIKE bdcdata.
Work Area for BDC Messages
DATA: wa_messtab LIKE bdcmsgcoll.
Work Area for Input file
DATA: wa_record TYPE ty_record.
V A R I A B L E S ****************************
DATA: v_filename TYPE string,
v_fnam(40) TYPE c.
DATA: wa_opt TYPE ctu_params.
C O N S T A N T S ***************************
CONSTANTS: c_werks TYPE rc27m-werks VALUE 'tp',
c_steus TYPE plpod-steus VALUE 'PP01'.
----
*Selection Screen.
----
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS:
Input file name
P_FILE TYPE rlgrap-filename OBLIGATORY. " DEFAULT 'C:\'.
SELECTION-SCREEN END OF BLOCK B1.
-
x----
&----
*& Include ZROUT_FORM *
&----
&----
*& Form f_fill_bdctab
&----
Form to fill the BDC Data
----
FORM f_fill_bdctab.
TABLES mapl. "Assignment of Task Lists to Materials
DATA: l_cnt_item(3) TYPE n VALUE 1. "Line item counter
DATA: first(3) TYPE n VALUE 16. "Line item counter
DATA: next(3) TYPE n . "Line item counter
DATA: lin(3) TYPE n . "Line item counter
DATA: l_v_bmsch(13), "Base qty
l_v_meinh(3), "Unit of Measure
l_v_vgw01(11), "Machine
l_v_vgw02(11), "Labour
l_v_vge01(3). "Unit of measure of activity
DATA l_v_nextline TYPE sy-tabix.
DATA wa_temp TYPE ty_record.
Initialize Counter
l_cnt_item = 1.
SORT i_record BY matnr.
LOOP AT i_record INTO wa_record.
AT NEW matnr.
REFRESH: i_bdcdata,
i_messtab.
SET PARAMETER ID 'PLN' FIELD space.
SET PARAMETER ID 'PAL' FIELD space.
PERFORM f_bdc_dynpro USING 'SAPLCPDI' '1010'.
PERFORM f_bdc_field USING 'BDC_OKCODE'
'/00'.
Material Number
PERFORM f_bdc_field USING 'RC27M-MATNR'
wa_record-matnr.
Plant
PERFORM f_bdc_field USING 'RC27M-WERKS'
c_werks.
PERFORM f_bdc_field USING 'RC271-PLNNR'
''.
Check if routing already exits for the material
SELECT * FROM mapl
INTO mapl
WHERE matnr EQ wa_record-matnr
AND werks EQ c_werks
AND plnty EQ 'N'.
IF sy-subrc EQ 0.
PERFORM f_bdc_dynpro USING 'SAPLCPDI' '1200'.
PERFORM f_bdc_field USING 'BDC_OKCODE'
'=ANLG '.
ENDIF.
ENDSELECT.
perform f_bdc_dynpro USING 'SAPLCPDA' '1200'.
perform f_bdc_field USING 'BDC_OKCODE'
'=VOUE'.
Group Counter
perform f_bdc_field USING 'PLKOD-PLNAL'
''.
Usage
PERFORM f_bdc_field USING 'PLKOD-VERWE'
'1'.
Status
PERFORM f_bdc_field USING 'PLKOD-STATU'
'4'.
ENDAT.
PERFORM f_bdc_dynpro USING 'SAPLCPDI' '1400'.
Check if page is full
IF l_cnt_item EQ '16'.
Page down
PERFORM f_bdc_field USING 'BDC_OKCODE'
'=P+'.
l_cnt_item = 1.
ELSE.
PERFORM f_bdc_field USING 'BDC_OKCODE'
'/00'.
ENDIF.
CLEAR v_fnam.
Populate item level details
Work Center
CONCATENATE 'PLPOD-ARBPL(' l_cnt_item ')' INTO v_fnam.
PERFORM f_bdc_field USING v_fnam
wa_record-arbpl.
Control Key
CONCATENATE 'PLPOD-STEUS(' l_cnt_item ')' INTO v_fnam.
PERFORM f_bdc_field USING v_fnam
c_steus.
Description of Operation
CONCATENATE 'PLPOD-LTXA1(' l_cnt_item ')' INTO v_fnam.
PERFORM f_bdc_field USING v_fnam
wa_record-ltxa1.
Base Quantity
CONCATENATE 'PLPOD-BMSCH(' l_cnt_item ')' INTO v_fnam.
PERFORM f_bdc_field USING v_fnam
wa_record-bmsch.
Unit of Measure
CONCATENATE 'PLPOD-MEINH(' l_cnt_item ')' INTO v_fnam.
PERFORM f_bdc_field USING v_fnam
wa_record-meinh.
Machine
CONCATENATE 'PLPOD-VGW01(' l_cnt_item ')' INTO v_fnam.
PERFORM f_bdc_field USING v_fnam
wa_record-vgw01.
Labour
CONCATENATE 'PLPOD-VGW02(' l_cnt_item ')' INTO v_fnam.
*
PERFORM f_bdc_field USING v_fnam
wa_record-vgw02.
Unit of measure of activity
CONCATENATE 'PLPOD-VGE01(' l_cnt_item ')' INTO v_fnam.
PERFORM f_bdc_field USING v_fnam
wa_record-vge01.
l_cnt_item = l_cnt_item + 1.
CLEAR wa_record.
AT END OF matnr.
PERFORM f_bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM f_bdc_field USING 'BDC_OKCODE'
'=BU'.
wa_opt-DISMODE = 'A'.
wa_opt-DEFSIZE = 'X'.
wa_opt-UPDMODE = 'S'.
PERFORM f_bdc_transaction USING 'CA01'.
Initialize Counter
l_cnt_item = 1.
ENDAT.
ENDLOOP.
ENDFORM. " f_fill_bdctab
-
x----
&----
*& Include ZROUT_INCLUDE_F_CA01 *
&----
&----
*& Form f_read_file
&----
Form to read the file from presentation server
----
FORM f_read_file .
To get the file name
DATA l_v_file TYPE string.
l_v_file = P_FILE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_v_file
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = i_record
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 <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDFORM. " f_read_file
&----
*& Form f_bdc_dynpro
&----
Form to populate BDC Tab for new screen
----
-->fp_program Screen program name
-->fp_dynpro Screen Number
----
Start new screen *
----
FORM f_bdc_dynpro USING fp_program fp_dynpro.
CLEAR wa_bdcdata.
wa_bdcdata-program = fp_program.
wa_bdcdata-dynpro = fp_dynpro.
wa_bdcdata-dynbegin = 'X'.
APPEND wa_bdcdata TO i_bdcdata.
ENDFORM. "f_bdc_dynpro
&----
*& Form f_bdc_field
&----
Insert field *
----
FORM f_bdc_field USING fp_fnam fp_fval.
IF NOT fp_fval IS INITIAL.
CLEAR wa_bdcdata.
wa_bdcdata-fnam = fp_fnam.
wa_bdcdata-fval = fp_fval.
APPEND wa_bdcdata TO i_bdcdata.
ENDIF.
ENDFORM. "f_bdc_field
&----
*& Form f_bdc_transaction
&----
Call transaction and error handling
----
-->fp_tcode Transaction code
----
FORM f_bdc_transaction USING fp_tcode.
DATA: l_mstring(480),
l_color TYPE i,
l_mode TYPE c.
REFRESH i_messtab.
CALL TRANSACTION fp_tcode USING i_bdcdata
OPTIONS FROM wa_opt
MESSAGES INTO i_messtab.
Messages during upload
LOOP AT i_messtab INTO wa_messtab.
CASE wa_messtab-msgtyp.
WHEN 'S'.
l_color = 5.
WHEN 'E'.
l_color = 6.
WHEN 'W'.
l_color = 3.
ENDCASE.
FORMAT COLOR = l_color.
SELECT SINGLE * FROM t100 WHERE sprsl = wa_messtab-msgspra
AND arbgb = wa_messtab-msgid
AND msgnr = wa_messtab-msgnr.
IF sy-subrc = 0.
l_mstring = t100-text.
IF l_mstring CS '&1'.
REPLACE '&1' WITH wa_messtab-msgv1 INTO l_mstring.
REPLACE '&2' WITH wa_messtab-msgv2 INTO l_mstring.
REPLACE '&3' WITH wa_messtab-msgv3 INTO l_mstring.
REPLACE '&4' WITH wa_messtab-msgv4 INTO l_mstring.
ELSE.
REPLACE '&' WITH wa_messtab-msgv1 INTO l_mstring.
REPLACE '&' WITH wa_messtab-msgv2 INTO l_mstring.
REPLACE '&' WITH wa_messtab-msgv3 INTO l_mstring.
REPLACE '&' WITH wa_messtab-msgv4 INTO l_mstring.
ENDIF.
CONDENSE l_mstring.
WRITE: / wa_messtab-msgtyp, l_mstring(250).
ELSE.
WRITE: / wa_messtab.
ENDIF.
FORMAT COLOR OFF.
ENDLOOP.
SKIP.
ENDFORM. " f_bdc_transaction
FORM F1001_GET_F4.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = SY-REPID
DYNPRO_NUMBER = SY-DYNNR
FIELD_NAME = P_FILE
CHANGING
FILE_NAME = P_FILE
EXCEPTIONS
MASK_TOO_LONG = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
File is not selected
MESSAGE I000 WITH TEXT-M01.
ENDIF.
ENDFORM. " F1001_GET_F4
09-26-2007 6:15 AM
09-26-2007 2:53 PM
Hi Sudipta,
pls forward routing template file send to my e-mail id
msankar1980@gmail.com
thanks & regards,
Sankaran
09-28-2007 5:52 AM
Hi Sankaran,
As requested, please find my Routing Template attached herewith. Its a VERY URGENT BDC requirement Kindly help me at the earliest.
Thanks & Regards
Sudipta
09-26-2007 7:12 PM
Instead of BDC, You can use the BAPI "'BAPI_ROUTING_CREATE" to create the Routings easily.
Thanks
Shekar