2007 Apr 23 9:38 AM
can anyone expalin how to do bdc recording step by step also i have a flat file with values after doing recording i have values which i entered in selection screen in the program how can i put that in a loop so that it should take that input automatically without manual entry for each entry ........
please explain recording step by step very urgent
2007 Apr 23 9:54 AM
REPORT ydpurc_conditiontype MESSAGE-ID yd01 LINE-SIZE 300 LINE-COUNT 65 NO STANDARD PAGE HEADING .
CONSTANTS: gc_read TYPE dxfields-fileoper VALUE 'R', " Constants used in form file selection.
gc_applic TYPE dxfields-location VALUE 'A', " file in application server
gc_presen TYPE dxfields-location VALUE 'P', " file in presentation server
gc_root(01) TYPE c VALUE '/', " used in file selection if the file path is empty
gc_date TYPE sy-datum VALUE '99991231', " date
gc_mode TYPE c VALUE 'A', " all screen mode
gc_mode1 TYPE c VALUE 'N', " no screen mode
gc_flag TYPE c VALUE 'x', " flag value initialsed to x
gc_dynbegin TYPE c VALUE 'x', " dynbegin
gc_sucess TYPE c VALUE 'S' , " contant used for checking if records are fetched
gc_tcode(4) TYPE c VALUE 'MEK1'. " transaction used for the conversion
DATA: gv_line TYPE i, "Varibles
gv_line1 TYPE i,
gv_line2 TYPE i,
gv_datab TYPE char12, "Varible to hold the data
gv_date TYPE char2, "Varible to hold the date
gv_mon TYPE char2, "Varible to hold the month
gv_year TYPE char4, "Varible to hold the year
gv_msg TYPE char100, "Varible to hold Bdc messages
gv_no_succs TYPE i, "Varible to hold the no of sucess records
gv_no_error TYPE i. "Variable to hold no of error records
******************************************************************************************
*selcection screen to let the user select the condition type,currentdate,enddate********
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-028.
PARAMETERS: p_cndtyp TYPE rv13a-kschl DEFAULT 'zhts', "condition type
p_delcnt TYPE komg-hland DEFAULT 'CA', "delivery country
p_crdate TYPE rv13a-datab DEFAULT sy-datum, "current date
p_edate TYPE rv13a-datbi DEFAULT gc_date. "enddate
SELECTION-SCREEN END OF BLOCK b2.
*****************************************************************************************************************************
*selection screen to let the user select between presentation server and application server and whether to run in test mode*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-029.
PARAMETERS: p_upl_ps RADIOBUTTON GROUP g1 DEFAULT 'X' USER-COMMAND upl, "presentation server
p_upl_as RADIOBUTTON GROUP g1, "application server
p_path TYPE rlgrap-filename , "file path
p_test AS CHECKBOX. "test mode
SELECTION-SCREEN END OF BLOCK b1.
************************************************************************************************
&**************************************TYPES***********************************************&
TYPES: BEGIN OF gst_stritab, " Structure to hold lagacy data
hland TYPE komg-hland, "delivering country
sku(10) TYPE c, "sku
description(30) TYPE c, "description
herkl TYPE komg-herkl, "country of origin
coimp TYPE komg-coimp, "import code
coimp1 TYPE komg-coimp,
chdate TYPE date, "date
gstcode(10) TYPE c, "gstcode
annex(10) TYPE c, "annex
kbetr TYPE rv13a-konwa, "rate
ust(10) TYPE c, "ust
END OF gst_stritab.
***********************************************************************************************************
TYPES: BEGIN OF gst_e_stritab, "structure for error's
hland TYPE komg-hland, "delivering country
sku(10) TYPE c, "sku
description(30) TYPE c, "description
herkl TYPE komg-herkl, "country of origin
coimp TYPE komg-coimp, "import code
coimp1 TYPE komg-coimp,
chdate TYPE date, "change date
gstcode(10) TYPE c, "gst code
annex(10) TYPE c, "annex
kbetr TYPE rv13a-konwa, "rate
ust(10) TYPE c, "ust
error_desc(100) TYPE c, "Error description
END OF gst_e_stritab.
***************************************************************************************************************
TYPES: BEGIN OF gst_t_stritab, "structure to hold lagacy data in which mfn or gpt is given
hland TYPE komg-hland, "delivering country
sku(10) TYPE c,
description(30) TYPE c,
herkl TYPE komg-herkl, "country of origin
coimp TYPE komg-coimp, "import code
coimp1 TYPE komg-coimp,
chdate TYPE date ,
gstcode(10) TYPE c,
annex(10) TYPE c,
mfn(10) TYPE c, "most favoured nation rate
gpt(10) TYPE c , "general preferential treatment rate
ust(10) TYPE c,
END OF gst_t_stritab.
*******************************************************************************************************************
TYPES: BEGIN OF gst_temp_str, "structure to hold the data from the flat file
line(1000) TYPE c,
END OF gst_temp_str.
********************************************************************************************************************
TYPES:BEGIN OF gst_hland_coimp, "structure to hold the delivery country and import code for validations
hland TYPE hland, "delivery country
coimp TYPE coimp, "import code
END OF gst_hland_coimp.
******************************************************************************************************************
TYPES:BEGIN OF gst_herkl, "structure to hold country of origin for validatons
herkl TYPE herkl, "country of origin
END OF gst_herkl.
*******************************************************************************************************************
TYPES: BEGIN OF gst_msg, "structure to hold messages
msg TYPE char100,
END OF gst_msg.
***********************************************************************
***************INTERNAL TABLES**************************************
DATA: gi_temp TYPE STANDARD TABLE OF gst_temp_str. "internal table for structure gst_tem_str
DATA: gi_stritab TYPE STANDARD TABLE OF gst_stritab . "internal table to hold legacy data
DATA: gi_hland_coimp TYPE STANDARD TABLE OF gst_hland_coimp. "internal table used for delivery countryand import code validations
DATA: gi_herkl TYPE STANDARD TABLE OF gst_herkl. "internal table used for country of origin validations
DATA: gi_c1_stritab TYPE STANDARD TABLE OF gst_stritab. "internal table used to hold data that will be uploaded to bdc
DATA: gi_c_stritab TYPE STANDARD TABLE OF gst_stritab. "internal table to hold correct data for validations done for hland/coimp
DATA: gi_t_stritab TYPE STANDARD TABLE OF gst_t_stritab. "internal table to store data including values for either mnf or gpt
DATA: gi_e_stritab TYPE STANDARD TABLE OF gst_e_stritab. "internal table to store error records
DATA: gi_messtab TYPE TABLE OF bdcmsgcoll. "Internal table for to read unix data
DATA: gi_msg TYPE TABLE OF gst_msg. "internal table to store messages
DATA: gi_bdcdata TYPE TABLE OF bdcdata. "Internal table for bdcdata
********************WORK AREAS*************************************************
DATA: gw_itab TYPE gst_stritab. "work area for structure gst_stritab
DATA: gw_temp TYPE gst_temp_str. "work area for structure gst_temp_str
DATA: gw_e_stritab TYPE gst_e_stritab. "work area for structure gst_e_stritab
DATA: gw_c_stritab TYPE gst_stritab. "work area for structure gst_stritab
DATA: gw_t_stritab TYPE gst_t_stritab. "work area for structure gst_t_stritab
DATA: gw_hland_coimp TYPE gst_hland_coimp. "Work area for structure gst_hland_coimp
DATA: gw_herkl TYPE gst_herkl. "Work area for structure gst_herkl
DATA: gw_messtab TYPE bdcmsgcoll. "work area for structure bdcmsgcoll
DATA: gw_bdcdata TYPE bdcdata. "work area for structure bdcdata
*******************************************************************
----
*At Selection-Screen on value-request
----
**at selection screen****
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
PERFORM gf_file_selection. "Subroutine for file selection
*----
**Top-Of-Page
*----
TOP-OF-PAGE.
PERFORM gf_header. "Subroutine for Header
**********************************************************************************
----
*Start-Of-Selection
----
START-OF-SELECTION.
IF p_path IS INITIAL.
SET CURSOR FIELD 'P_PATH'.
MESSAGE s020 DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
CLEAR: gi_messtab.
REFRESH: gi_messtab.
PERFORM gf_upload_file. "Subroutine for upload file
IF NOT p_test IS INITIAL. "Check Condition
PERFORM gf_validation. "Subroutine for Validations
IF gi_e_stritab[] IS NOT INITIAL. "if error table is not empty
PERFORM gf_display_data. "then no upload for those records only display
ELSE.
PERFORM gf_bdc_result.
ENDIF.
ELSE.
PERFORM gf_validation. " Subroutine for display error log.
CLEAR:gv_no_succs,gv_no_error,gv_msg, gi_msg.
REFRESH: gi_msg.
PERFORM gf_run_bdc. " Subroutine for Run BDC
IF gi_e_stritab[] IS NOT INITIAL.
PERFORM gf_display_data.
ELSE.
PERFORM gf_bdc_result. " Subroutine for Display bdc result and outputs
ENDIF.
ENDIF.
END-OF-SELECTION.
EXIT.
&----
*& Form file_selection
&----
FORM gf_file_selection.
CONSTANTS: lc_slash(2) TYPE c VALUE '//'.
DATA : lv_file_path TYPE dxfields-longpath, "path of the file
lv_location TYPE dxfields-location, "location whether application or presentation
lv_server TYPE msxxlist-name, "application server name
lw_rfcsi TYPE rfcsi. "system information
CLEAR:lv_server,lv_location, lv_file_path.
MOVE gc_read TO lv_file_path.
IF lv_file_path IS INITIAL. "if file path is empty
lv_file_path = gc_root.
ENDIF.
IF NOT p_upl_ps IS INITIAL.
lv_location = gc_presen. "if presentation server is selected
ELSE .
lv_location = gc_applic. "if application server is selected
ENDIF.
CALL FUNCTION 'RFC_SYSTEM_INFO'
IMPORTING
rfcsi_export = lw_rfcsi.
lv_server = lw_rfcsi-rfcdest.
CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION' "selecting the file
EXPORTING
i_location_flag = lv_location
i_server = lv_server
i_path = lv_file_path
fileoperation = p_upl_ps
IMPORTING
o_path = lv_file_path
EXCEPTIONS
rfc_error = 1
OTHERS = 2
.
IF sy-subrc NE 0.
EXIT.
ELSE.
MOVE lv_file_path TO p_path.
ENDIF.
IF p_path(2) EQ lc_slash.
SHIFT p_path LEFT.
ENDIF.
ENDFORM. " FILE_SELECTION
&----
*& Form gf_upload_file
&----
FORM gf_upload_file. "uploading the file
DATA: lv_path TYPE string.
CLEAR: gi_temp,gi_stritab,lv_path.
REFRESH: gi_temp,gi_stritab.
IF NOT p_upl_ps IS INITIAL. "IF the data is availabe on the presentation server then get the data
lv_path = p_path.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lv_path
filetype = 'ASC'
TABLES
data_tab = gi_temp
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 NE 0.
CASE sy-subrc.
WHEN 1.
MESSAGE s003 DISPLAY LIKE 'E'. "Error opening the file
LEAVE LIST-PROCESSING.
WHEN 2.
MESSAGE s004 DISPLAY LIKE 'E'. "Error reading the file
LEAVE LIST-PROCESSING.
WHEN OTHERS.
MESSAGE s007 DISPLAY LIKE 'E'.
ENDCASE.
ENDIF.
ELSE. "APPLICATION SERVER
DATA: lv_msg TYPE string.
CLEAR lv_msg.
OPEN DATASET p_path FOR INPUT IN TEXT MODE ENCODING DEFAULT WITH SMART LINEFEED.
IF sy-subrc EQ 8.
MESSAGE s021 DISPLAY LIKE 'E'. "Error opening the file
LEAVE LIST-PROCESSING.
ENDIF.
DO.
READ DATASET p_path INTO gw_temp-line. "Read file which is opened.
IF sy-subrc EQ 0.
APPEND gw_temp TO gi_temp.
ELSE.
EXIT.
ENDIF.
CLEAR gw_temp.
ENDDO.
CLOSE DATASET p_path.
ENDIF.
LOOP AT gi_temp INTO gw_temp.
PERFORM lf_f_split_upload_data. "Splitting the data into columns of internal table
CLEAR gw_temp.
ENDLOOP.
ENDFORM. " UPLOAD_FILE
----
Form lf_bdc_transaction *
----
FORM lf_bdc_transaction USING x_tcode TYPE any. "BDC Transaction for doing the upload
DATA: lv_flag TYPE c.
CALL TRANSACTION x_tcode USING gi_bdcdata
MODE gc_mode
UPDATE gc_mode1
MESSAGES INTO gi_messtab.
IF sy-subrc NE 0.
EXIT.
ENDIF.
CLEAR: lv_flag.
LOOP AT gi_messtab INTO gw_messtab. "loop at gi_messtab into gw_messtab
IF gw_messtab-msgtyp EQ gc_sucess. "if message type is equal to gc_success
IF lv_flag EQ space. "and if lv_flag is not set
gv_no_succs = gv_no_succs + 1. "set gv_no_sucess to gv_no_sucess+1
lv_flag = gc_flag. "set the flag to 's'
ENDIF.
ELSE.
CALL FUNCTION 'MESSAGE_TEXT_BUILD' "putting the error into the table
EXPORTING
msgid = gw_messtab-msgid
msgnr = gw_messtab-msgnr
msgv1 = gw_messtab-msgv1
msgv2 = gw_messtab-msgv2
msgv3 = gw_messtab-msgv3
msgv4 = gw_messtab-msgv4
IMPORTING
message_text_output = gv_msg.
APPEND gv_msg TO gi_msg.
IF lv_flag EQ space.
gv_no_error = gv_no_error + 1. "increment the no of errors
lv_flag = gc_flag.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. "lf_bdc_transaction
*----
Form bdc_dynpro *
*----
FORM lf_bdc_dynpro USING x_program TYPE any x_dynpro TYPE any. "for setting the screen number BDC sturucture
CLEAR gw_bdcdata.
gw_bdcdata-program = x_program.
gw_bdcdata-dynpro = x_dynpro.
gw_bdcdata-dynbegin = gc_dynbegin.
APPEND gw_bdcdata TO gi_bdcdata.
ENDFORM. "lf_bdc_dynpro
*----
Form bdc_field *
*----
FORM lf_bdc_field USING x_fnam TYPE any x_fval TYPE any. "for setting the bdc field
IF NOT x_fval IS INITIAL.
CLEAR gw_bdcdata.
gw_bdcdata-fnam = x_fnam.
gw_bdcdata-fval = x_fval.
APPEND gw_bdcdata TO gi_bdcdata.
ENDIF.
ENDFORM. "lf_bdc_field
*****************************************************************************************************
************************************************************************************************
FORM lf_f_split_upload_data. "function to split the data uploaded into internal table from legacy using pipe"|" delimiter
IF gi_temp[] IS INITIAL.
WRITE: /5 text-030.
EXIT.
ELSE.
LOOP AT gi_temp INTO gw_temp.
SPLIT gw_temp-line AT '|' INTO gw_t_stritab-sku gw_t_stritab-description gw_t_stritab-herkl gw_t_stritab-coimp gw_t_stritab-coimp1 gw_t_stritab-chdate gw_t_stritab-gstcode gw_t_stritab-annex gw_t_stritab-mfn gw_t_stritab-gpt gw_t_stritab-ust.
"table gi_temp
gw_t_stritab-hland = 'CA'.
APPEND gw_t_stritab TO gi_t_stritab.
ENDLOOP.
CLEAR:gw_t_stritab,gi_temp.
ENDIF.
ENDFORM. "lf_f_split_upload_data
*******************************************************************************************************
FORM gf_run_bdc . "for running the trnsaction BDC using MEK1 Transaction.
CONSTANTS: lc_slash TYPE c VALUE '/'.
CLEAR: gv_year, gv_mon, gv_date, gi_bdcdata, gv_datab.
REFRESH gi_bdcdata.
MOVE: sy-datum+0(4) TO gv_year, "Todays date.
sy-datum+4(2) TO gv_mon,
sy-datum+6(2) TO gv_date.
CONCATENATE gv_mon lc_slash gv_date lc_slash gv_year INTO gv_datab.
LOOP AT gi_c1_stritab INTO gw_itab.
PERFORM lf_bdc_dynpro USING 'SAPMV13A' '0100'.
PERFORM lf_bdc_field USING text-041
'RV13A-KSCHL'.
PERFORM lf_bdc_field USING text-040
'=ANTA'.
PERFORM lf_bdc_field USING 'RV13A-KSCHL'
'zhts'.
PERFORM lf_bdc_dynpro USING 'SAPLV14A' '0100'.
PERFORM lf_bdc_field USING text-041
'RV130-SELKZ(01)'.
PERFORM lf_bdc_field USING text-040
'=WEIT'.
PERFORM lf_bdc_dynpro USING 'SAPMV13A' '1317'.
PERFORM lf_bdc_field USING text-041
'KONP-VALTG(01)'.
PERFORM lf_bdc_field USING text-040
'=SICH'.
PERFORM lf_bdc_field USING 'KOMG-HLAND'
p_delcnt . "gw_itab-HLAND.
PERFORM lf_bdc_field USING 'KOMG-COIMP'
gw_itab-coimp.
PERFORM lf_bdc_field USING 'KOMG-HERKL(01)'
gw_itab-herkl.
PERFORM lf_bdc_field USING 'KONP-KBETR(01)'
gw_itab-kbetr.
PERFORM lf_bdc_field USING 'RV13A-DATAB(01)'
gv_datab.
PERFORM lf_bdc_field USING 'RV13A-DATBI(01)'
p_edate.
PERFORM lf_bdc_transaction USING gc_tcode.
REFRESH gi_bdcdata.
ENDLOOP.
ENDFORM. "gf_run_bdc
*************************FORM FILL_INTERNAL_TABLE**********************************
&**********************************************************************************
FORM gf_validation.
LOOP AT gi_t_stritab INTO gw_t_stritab.
gw_itab-hland = gw_t_stritab-hland.
gw_itab-sku = gw_t_stritab-sku.
gw_itab-description = gw_t_stritab-description.
gw_itab-herkl = gw_t_stritab-herkl.
gw_itab-coimp = gw_t_stritab-coimp.
gw_itab-coimp1 = gw_t_stritab-coimp1.
gw_itab-chdate = gw_t_stritab-chdate.
gw_itab-gstcode = gw_t_stritab-gstcode.
gw_itab-annex = gw_t_stritab-annex.
IF gw_t_stritab-mfn EQ space.
gw_itab-kbetr = gw_t_stritab-gpt.
ELSE.
gw_itab-kbetr = gw_t_stritab-mfn.
ENDIF.
gw_itab-ust = gw_t_stritab-ust.
APPEND gw_itab TO gi_stritab.
ENDLOOP.
CLEAR gi_t_stritab.
REFRESH gi_t_stritab.
CLEAR gi_hland_coimp.
REFRESH gi_hland_coimp.
SELECT land1 stawn "validation to check whether delivering country and import code is valid or not
FROM t604
INTO TABLE gi_hland_coimp
FOR ALL ENTRIES IN gi_stritab
WHERE land1 = gi_stritab-hland
AND stawn = gi_stritab-coimp.
IF sy-subrc NE 0.
WRITE:''.
ENDIF.
LOOP AT gi_stritab INTO gw_itab.
SORT gi_hland_coimp BY hland coimp. "sort table gi_hland_coimp
READ TABLE gi_hland_coimp INTO gw_hland_coimp WITH KEY hland = gw_itab-hland
coimp = gw_itab-coimp BINARY SEARCH. "read table gi_hland_coimp with key
IF sy-subrc NE 0. "if delivering country/import code combination is not valid
gw_e_stritab-hland = gw_itab-hland.
gw_e_stritab-sku = gw_itab-sku.
gw_e_stritab-description = gw_itab-description.
gw_e_stritab-herkl = gw_itab-herkl.
gw_e_stritab-coimp = gw_itab-coimp.
gw_e_stritab-chdate = gw_itab-chdate.
gw_e_stritab-gstcode = gw_itab-gstcode.
gw_e_stritab-annex = gw_itab-annex.
gw_e_stritab-kbetr = gw_itab-kbetr.
gw_e_stritab-ust = gw_itab-ust.
gw_e_stritab-error_desc = text-005.
APPEND gw_e_stritab TO gi_e_stritab. "append to error table
CONTINUE.
ELSE. "if delivering country/import code is valid
gw_c_stritab-hland = gw_itab-hland.
gw_c_stritab-sku = gw_itab-sku.
gw_c_stritab-description = gw_itab-description.
gw_c_stritab-herkl = gw_itab-herkl.
gw_c_stritab-coimp = gw_itab-coimp.
gw_c_stritab-chdate = gw_itab-chdate.
gw_c_stritab-gstcode = gw_itab-gstcode.
gw_c_stritab-annex = gw_itab-annex.
gw_c_stritab-kbetr = gw_itab-kbetr.
gw_c_stritab-ust = gw_itab-ust.
APPEND gw_c_stritab TO gi_c_stritab. "aappend to correct internal table
ENDIF.
ENDLOOP.
SELECT "validation to check whether the country of origin is valid
land1
FROM
t005
INTO
TABLE gi_herkl
FOR ALL ENTRIES IN gi_c_stritab
WHERE
land1 = gi_c_stritab-herkl.
IF sy-subrc NE 0.
WRITE:''.
ENDIF.
LOOP AT gi_c_stritab INTO gw_itab.
SORT gi_herkl BY herkl.
READ TABLE gi_herkl INTO gw_herkl WITH KEY herkl = gw_itab-herkl. "read table with key
IF sy-subrc NE 0. "if the country of origin is not valid
gw_e_stritab-hland = gw_itab-hland.
gw_e_stritab-sku = gw_itab-sku.
gw_e_stritab-description = gw_itab-description.
gw_e_stritab-herkl = gw_itab-herkl.
gw_e_stritab-coimp = gw_itab-coimp.
gw_e_stritab-chdate = gw_itab-chdate.
gw_e_stritab-gstcode = gw_itab-gstcode.
gw_e_stritab-annex = gw_itab-annex.
gw_e_stritab-kbetr = gw_itab-kbetr.
gw_e_stritab-ust = gw_itab-ust.
gw_e_stritab-error_desc = text-002.
APPEND gw_e_stritab TO gi_e_stritab. "append to error internal table
CONTINUE.
ELSE. "if the country of origin is valid
gw_c_stritab-hland = gw_itab-hland.
gw_c_stritab-sku = gw_itab-sku.
gw_c_stritab-description = gw_itab-description.
gw_c_stritab-herkl = gw_itab-herkl.
gw_c_stritab-coimp = gw_itab-coimp.
gw_c_stritab-chdate = gw_itab-chdate.
gw_c_stritab-gstcode = gw_itab-gstcode.
gw_c_stritab-annex = gw_itab-annex.
gw_c_stritab-kbetr = gw_itab-kbetr.
gw_c_stritab-ust = gw_itab-ust.
APPEND gw_c_stritab TO gi_c1_stritab. "append to correct internal table
ENDIF.
ENDLOOP.
CLEAR gi_herkl.
REFRESH gi_herkl.
CLEAR gi_c_stritab.
REFRESH gi_c_stritab.
ENDFORM. "gf_validation
&************************************************
************FORM gf_display_data.
&************************************************
FORM gf_display_data.
IF NOT gi_e_stritab IS INITIAL. "if the error table is not empty
LOOP AT gi_e_stritab INTO gw_e_stritab.
WRITE:/ gw_e_stritab-hland, 21 gw_e_stritab-sku,30 gw_e_stritab-description, 76 gw_e_stritab-herkl,88 gw_e_stritab-coimp,106 gw_e_stritab-chdate,126 gw_e_stritab-gstcode,135 gw_e_stritab-annex,176 gw_e_stritab-kbetr,195 gw_e_stritab-ust,
205 gw_e_stritab-error_desc.
ENDLOOP.
ULINE.
DESCRIBE TABLE gi_e_stritab LINES gv_line. "describe error internal table
WRITE:/ text-004, 55 gv_line.
CLEAR gi_e_stritab.
REFRESH gi_e_stritab.
DESCRIBE TABLE gi_stritab LINES gv_line1. "describe internal table containing legacy data
WRITE:/ text-003, 55 gv_line1.
IF p_test IS NOT INITIAL. "if the test button is checked
CLEAR gi_c1_stritab.
REFRESH gi_c1_stritab.
DESCRIBE TABLE gi_c1_stritab LINES gv_line2. "describe the no of records in the correct internal table
WRITE:/ text-026,55 gv_line2.
ELSE.
gv_line2 = gv_line1 - gv_line.
DESCRIBE TABLE gi_c1_stritab LINES gv_line2.
WRITE:/ text-026,55 gv_line2.
ENDIF.
CLEAR gv_line1.
CLEAR gv_line.
CLEAR gv_line2.
FREE:gi_e_stritab.
ENDIF.
ENDFORM. " display_data
&**************************************************************************************************&
FORM GF_HEADER
&**************************************************************************************************&
&----
*& Form GF_HEADER
&----
FORM gf_header.
NEW-LINE. " Dispalay the header section
ULINE.
WRITE:/ text-006.
WRITE:/ text-007.
SKIP 1.
WRITE: AT /1 'PROGRAM NAME:'(022),sy-repid,
'DATE :'(023),sy-datum,
AT 100 'TIME :'(024),sy-timlo.
WRITE: AT /1 'FILENAME:'(025),p_path.
ULINE.
SKIP 1.
WRITE:/ text-008.
WRITE:/ text-009.
WRITE:/ text-010.
WRITE: AT 23 text-031.
WRITE: AT 33 text-032.
WRITE: AT 66 text-033.
WRITE: AT 87 text-034.
WRITE: AT 105 text-035.
WRITE: AT 123 text-036.
WRITE: AT 153 text-037.
WRITE: AT 173 text-038.
WRITE: AT 193 text-039.
WRITE: AT 213 text-021.
ULINE.
NEW-LINE.
NEW-LINE.
ENDFORM. " HEADER
&----
*& Form GF_BDC_RESULT
&----
FORM gf_bdc_result . "Displays the how many records loaded in SAP
LOOP AT gi_msg INTO gv_msg.
WRITE:/ gv_msg.
ENDLOOP.
LOOP AT gi_c1_stritab INTO gw_c_stritab.
WRITE:/ gw_c_stritab-hland, 21 gw_c_stritab-sku,33 gw_c_stritab-description, 70 gw_c_stritab-herkl,86 gw_c_stritab-coimp,106 gw_c_stritab-chdate,126 gw_c_stritab-gstcode,146 gw_c_stritab-annex,173 gw_c_stritab-kbetr,194 gw_c_stritab-ust.
ENDLOOP.
ULINE.
DESCRIBE TABLE gi_msg LINES gv_line1.
gv_line1 = gv_line1 + gv_line.
WRITE:/ text-026, 55 gv_no_succs.
WRITE:/ text-027, 55 gv_line1.
CLEAR: gv_line1,gv_line.
DESCRIBE TABLE gi_stritab LINES gv_line1.
WRITE:/ text-003, 55 gv_line1.
CLEAR gi_stritab.
REFRESH gi_stritab.
ENDFORM. " BDC_RESULT
*******end of code****************************************************************
check this code hope this answers ur query!!!plss reward if useful!!
can anyone expalin how to do bdc recording step by step also i have a flat file with values after doing recording i have values which i entered in selection screen in the program how can i put that in a loop so that it should take that input automatically without manual entry for each entry ........
please explain recording step by step very urgent
2007 Apr 23 9:41 AM
2007 Apr 23 9:54 AM
REPORT ydpurc_conditiontype MESSAGE-ID yd01 LINE-SIZE 300 LINE-COUNT 65 NO STANDARD PAGE HEADING .
CONSTANTS: gc_read TYPE dxfields-fileoper VALUE 'R', " Constants used in form file selection.
gc_applic TYPE dxfields-location VALUE 'A', " file in application server
gc_presen TYPE dxfields-location VALUE 'P', " file in presentation server
gc_root(01) TYPE c VALUE '/', " used in file selection if the file path is empty
gc_date TYPE sy-datum VALUE '99991231', " date
gc_mode TYPE c VALUE 'A', " all screen mode
gc_mode1 TYPE c VALUE 'N', " no screen mode
gc_flag TYPE c VALUE 'x', " flag value initialsed to x
gc_dynbegin TYPE c VALUE 'x', " dynbegin
gc_sucess TYPE c VALUE 'S' , " contant used for checking if records are fetched
gc_tcode(4) TYPE c VALUE 'MEK1'. " transaction used for the conversion
DATA: gv_line TYPE i, "Varibles
gv_line1 TYPE i,
gv_line2 TYPE i,
gv_datab TYPE char12, "Varible to hold the data
gv_date TYPE char2, "Varible to hold the date
gv_mon TYPE char2, "Varible to hold the month
gv_year TYPE char4, "Varible to hold the year
gv_msg TYPE char100, "Varible to hold Bdc messages
gv_no_succs TYPE i, "Varible to hold the no of sucess records
gv_no_error TYPE i. "Variable to hold no of error records
******************************************************************************************
*selcection screen to let the user select the condition type,currentdate,enddate********
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-028.
PARAMETERS: p_cndtyp TYPE rv13a-kschl DEFAULT 'zhts', "condition type
p_delcnt TYPE komg-hland DEFAULT 'CA', "delivery country
p_crdate TYPE rv13a-datab DEFAULT sy-datum, "current date
p_edate TYPE rv13a-datbi DEFAULT gc_date. "enddate
SELECTION-SCREEN END OF BLOCK b2.
*****************************************************************************************************************************
*selection screen to let the user select between presentation server and application server and whether to run in test mode*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-029.
PARAMETERS: p_upl_ps RADIOBUTTON GROUP g1 DEFAULT 'X' USER-COMMAND upl, "presentation server
p_upl_as RADIOBUTTON GROUP g1, "application server
p_path TYPE rlgrap-filename , "file path
p_test AS CHECKBOX. "test mode
SELECTION-SCREEN END OF BLOCK b1.
************************************************************************************************
&**************************************TYPES***********************************************&
TYPES: BEGIN OF gst_stritab, " Structure to hold lagacy data
hland TYPE komg-hland, "delivering country
sku(10) TYPE c, "sku
description(30) TYPE c, "description
herkl TYPE komg-herkl, "country of origin
coimp TYPE komg-coimp, "import code
coimp1 TYPE komg-coimp,
chdate TYPE date, "date
gstcode(10) TYPE c, "gstcode
annex(10) TYPE c, "annex
kbetr TYPE rv13a-konwa, "rate
ust(10) TYPE c, "ust
END OF gst_stritab.
***********************************************************************************************************
TYPES: BEGIN OF gst_e_stritab, "structure for error's
hland TYPE komg-hland, "delivering country
sku(10) TYPE c, "sku
description(30) TYPE c, "description
herkl TYPE komg-herkl, "country of origin
coimp TYPE komg-coimp, "import code
coimp1 TYPE komg-coimp,
chdate TYPE date, "change date
gstcode(10) TYPE c, "gst code
annex(10) TYPE c, "annex
kbetr TYPE rv13a-konwa, "rate
ust(10) TYPE c, "ust
error_desc(100) TYPE c, "Error description
END OF gst_e_stritab.
***************************************************************************************************************
TYPES: BEGIN OF gst_t_stritab, "structure to hold lagacy data in which mfn or gpt is given
hland TYPE komg-hland, "delivering country
sku(10) TYPE c,
description(30) TYPE c,
herkl TYPE komg-herkl, "country of origin
coimp TYPE komg-coimp, "import code
coimp1 TYPE komg-coimp,
chdate TYPE date ,
gstcode(10) TYPE c,
annex(10) TYPE c,
mfn(10) TYPE c, "most favoured nation rate
gpt(10) TYPE c , "general preferential treatment rate
ust(10) TYPE c,
END OF gst_t_stritab.
*******************************************************************************************************************
TYPES: BEGIN OF gst_temp_str, "structure to hold the data from the flat file
line(1000) TYPE c,
END OF gst_temp_str.
********************************************************************************************************************
TYPES:BEGIN OF gst_hland_coimp, "structure to hold the delivery country and import code for validations
hland TYPE hland, "delivery country
coimp TYPE coimp, "import code
END OF gst_hland_coimp.
******************************************************************************************************************
TYPES:BEGIN OF gst_herkl, "structure to hold country of origin for validatons
herkl TYPE herkl, "country of origin
END OF gst_herkl.
*******************************************************************************************************************
TYPES: BEGIN OF gst_msg, "structure to hold messages
msg TYPE char100,
END OF gst_msg.
***********************************************************************
***************INTERNAL TABLES**************************************
DATA: gi_temp TYPE STANDARD TABLE OF gst_temp_str. "internal table for structure gst_tem_str
DATA: gi_stritab TYPE STANDARD TABLE OF gst_stritab . "internal table to hold legacy data
DATA: gi_hland_coimp TYPE STANDARD TABLE OF gst_hland_coimp. "internal table used for delivery countryand import code validations
DATA: gi_herkl TYPE STANDARD TABLE OF gst_herkl. "internal table used for country of origin validations
DATA: gi_c1_stritab TYPE STANDARD TABLE OF gst_stritab. "internal table used to hold data that will be uploaded to bdc
DATA: gi_c_stritab TYPE STANDARD TABLE OF gst_stritab. "internal table to hold correct data for validations done for hland/coimp
DATA: gi_t_stritab TYPE STANDARD TABLE OF gst_t_stritab. "internal table to store data including values for either mnf or gpt
DATA: gi_e_stritab TYPE STANDARD TABLE OF gst_e_stritab. "internal table to store error records
DATA: gi_messtab TYPE TABLE OF bdcmsgcoll. "Internal table for to read unix data
DATA: gi_msg TYPE TABLE OF gst_msg. "internal table to store messages
DATA: gi_bdcdata TYPE TABLE OF bdcdata. "Internal table for bdcdata
********************WORK AREAS*************************************************
DATA: gw_itab TYPE gst_stritab. "work area for structure gst_stritab
DATA: gw_temp TYPE gst_temp_str. "work area for structure gst_temp_str
DATA: gw_e_stritab TYPE gst_e_stritab. "work area for structure gst_e_stritab
DATA: gw_c_stritab TYPE gst_stritab. "work area for structure gst_stritab
DATA: gw_t_stritab TYPE gst_t_stritab. "work area for structure gst_t_stritab
DATA: gw_hland_coimp TYPE gst_hland_coimp. "Work area for structure gst_hland_coimp
DATA: gw_herkl TYPE gst_herkl. "Work area for structure gst_herkl
DATA: gw_messtab TYPE bdcmsgcoll. "work area for structure bdcmsgcoll
DATA: gw_bdcdata TYPE bdcdata. "work area for structure bdcdata
*******************************************************************
----
*At Selection-Screen on value-request
----
**at selection screen****
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
PERFORM gf_file_selection. "Subroutine for file selection
*----
**Top-Of-Page
*----
TOP-OF-PAGE.
PERFORM gf_header. "Subroutine for Header
**********************************************************************************
----
*Start-Of-Selection
----
START-OF-SELECTION.
IF p_path IS INITIAL.
SET CURSOR FIELD 'P_PATH'.
MESSAGE s020 DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
CLEAR: gi_messtab.
REFRESH: gi_messtab.
PERFORM gf_upload_file. "Subroutine for upload file
IF NOT p_test IS INITIAL. "Check Condition
PERFORM gf_validation. "Subroutine for Validations
IF gi_e_stritab[] IS NOT INITIAL. "if error table is not empty
PERFORM gf_display_data. "then no upload for those records only display
ELSE.
PERFORM gf_bdc_result.
ENDIF.
ELSE.
PERFORM gf_validation. " Subroutine for display error log.
CLEAR:gv_no_succs,gv_no_error,gv_msg, gi_msg.
REFRESH: gi_msg.
PERFORM gf_run_bdc. " Subroutine for Run BDC
IF gi_e_stritab[] IS NOT INITIAL.
PERFORM gf_display_data.
ELSE.
PERFORM gf_bdc_result. " Subroutine for Display bdc result and outputs
ENDIF.
ENDIF.
END-OF-SELECTION.
EXIT.
&----
*& Form file_selection
&----
FORM gf_file_selection.
CONSTANTS: lc_slash(2) TYPE c VALUE '//'.
DATA : lv_file_path TYPE dxfields-longpath, "path of the file
lv_location TYPE dxfields-location, "location whether application or presentation
lv_server TYPE msxxlist-name, "application server name
lw_rfcsi TYPE rfcsi. "system information
CLEAR:lv_server,lv_location, lv_file_path.
MOVE gc_read TO lv_file_path.
IF lv_file_path IS INITIAL. "if file path is empty
lv_file_path = gc_root.
ENDIF.
IF NOT p_upl_ps IS INITIAL.
lv_location = gc_presen. "if presentation server is selected
ELSE .
lv_location = gc_applic. "if application server is selected
ENDIF.
CALL FUNCTION 'RFC_SYSTEM_INFO'
IMPORTING
rfcsi_export = lw_rfcsi.
lv_server = lw_rfcsi-rfcdest.
CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION' "selecting the file
EXPORTING
i_location_flag = lv_location
i_server = lv_server
i_path = lv_file_path
fileoperation = p_upl_ps
IMPORTING
o_path = lv_file_path
EXCEPTIONS
rfc_error = 1
OTHERS = 2
.
IF sy-subrc NE 0.
EXIT.
ELSE.
MOVE lv_file_path TO p_path.
ENDIF.
IF p_path(2) EQ lc_slash.
SHIFT p_path LEFT.
ENDIF.
ENDFORM. " FILE_SELECTION
&----
*& Form gf_upload_file
&----
FORM gf_upload_file. "uploading the file
DATA: lv_path TYPE string.
CLEAR: gi_temp,gi_stritab,lv_path.
REFRESH: gi_temp,gi_stritab.
IF NOT p_upl_ps IS INITIAL. "IF the data is availabe on the presentation server then get the data
lv_path = p_path.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lv_path
filetype = 'ASC'
TABLES
data_tab = gi_temp
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 NE 0.
CASE sy-subrc.
WHEN 1.
MESSAGE s003 DISPLAY LIKE 'E'. "Error opening the file
LEAVE LIST-PROCESSING.
WHEN 2.
MESSAGE s004 DISPLAY LIKE 'E'. "Error reading the file
LEAVE LIST-PROCESSING.
WHEN OTHERS.
MESSAGE s007 DISPLAY LIKE 'E'.
ENDCASE.
ENDIF.
ELSE. "APPLICATION SERVER
DATA: lv_msg TYPE string.
CLEAR lv_msg.
OPEN DATASET p_path FOR INPUT IN TEXT MODE ENCODING DEFAULT WITH SMART LINEFEED.
IF sy-subrc EQ 8.
MESSAGE s021 DISPLAY LIKE 'E'. "Error opening the file
LEAVE LIST-PROCESSING.
ENDIF.
DO.
READ DATASET p_path INTO gw_temp-line. "Read file which is opened.
IF sy-subrc EQ 0.
APPEND gw_temp TO gi_temp.
ELSE.
EXIT.
ENDIF.
CLEAR gw_temp.
ENDDO.
CLOSE DATASET p_path.
ENDIF.
LOOP AT gi_temp INTO gw_temp.
PERFORM lf_f_split_upload_data. "Splitting the data into columns of internal table
CLEAR gw_temp.
ENDLOOP.
ENDFORM. " UPLOAD_FILE
----
Form lf_bdc_transaction *
----
FORM lf_bdc_transaction USING x_tcode TYPE any. "BDC Transaction for doing the upload
DATA: lv_flag TYPE c.
CALL TRANSACTION x_tcode USING gi_bdcdata
MODE gc_mode
UPDATE gc_mode1
MESSAGES INTO gi_messtab.
IF sy-subrc NE 0.
EXIT.
ENDIF.
CLEAR: lv_flag.
LOOP AT gi_messtab INTO gw_messtab. "loop at gi_messtab into gw_messtab
IF gw_messtab-msgtyp EQ gc_sucess. "if message type is equal to gc_success
IF lv_flag EQ space. "and if lv_flag is not set
gv_no_succs = gv_no_succs + 1. "set gv_no_sucess to gv_no_sucess+1
lv_flag = gc_flag. "set the flag to 's'
ENDIF.
ELSE.
CALL FUNCTION 'MESSAGE_TEXT_BUILD' "putting the error into the table
EXPORTING
msgid = gw_messtab-msgid
msgnr = gw_messtab-msgnr
msgv1 = gw_messtab-msgv1
msgv2 = gw_messtab-msgv2
msgv3 = gw_messtab-msgv3
msgv4 = gw_messtab-msgv4
IMPORTING
message_text_output = gv_msg.
APPEND gv_msg TO gi_msg.
IF lv_flag EQ space.
gv_no_error = gv_no_error + 1. "increment the no of errors
lv_flag = gc_flag.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. "lf_bdc_transaction
*----
Form bdc_dynpro *
*----
FORM lf_bdc_dynpro USING x_program TYPE any x_dynpro TYPE any. "for setting the screen number BDC sturucture
CLEAR gw_bdcdata.
gw_bdcdata-program = x_program.
gw_bdcdata-dynpro = x_dynpro.
gw_bdcdata-dynbegin = gc_dynbegin.
APPEND gw_bdcdata TO gi_bdcdata.
ENDFORM. "lf_bdc_dynpro
*----
Form bdc_field *
*----
FORM lf_bdc_field USING x_fnam TYPE any x_fval TYPE any. "for setting the bdc field
IF NOT x_fval IS INITIAL.
CLEAR gw_bdcdata.
gw_bdcdata-fnam = x_fnam.
gw_bdcdata-fval = x_fval.
APPEND gw_bdcdata TO gi_bdcdata.
ENDIF.
ENDFORM. "lf_bdc_field
*****************************************************************************************************
************************************************************************************************
FORM lf_f_split_upload_data. "function to split the data uploaded into internal table from legacy using pipe"|" delimiter
IF gi_temp[] IS INITIAL.
WRITE: /5 text-030.
EXIT.
ELSE.
LOOP AT gi_temp INTO gw_temp.
SPLIT gw_temp-line AT '|' INTO gw_t_stritab-sku gw_t_stritab-description gw_t_stritab-herkl gw_t_stritab-coimp gw_t_stritab-coimp1 gw_t_stritab-chdate gw_t_stritab-gstcode gw_t_stritab-annex gw_t_stritab-mfn gw_t_stritab-gpt gw_t_stritab-ust.
"table gi_temp
gw_t_stritab-hland = 'CA'.
APPEND gw_t_stritab TO gi_t_stritab.
ENDLOOP.
CLEAR:gw_t_stritab,gi_temp.
ENDIF.
ENDFORM. "lf_f_split_upload_data
*******************************************************************************************************
FORM gf_run_bdc . "for running the trnsaction BDC using MEK1 Transaction.
CONSTANTS: lc_slash TYPE c VALUE '/'.
CLEAR: gv_year, gv_mon, gv_date, gi_bdcdata, gv_datab.
REFRESH gi_bdcdata.
MOVE: sy-datum+0(4) TO gv_year, "Todays date.
sy-datum+4(2) TO gv_mon,
sy-datum+6(2) TO gv_date.
CONCATENATE gv_mon lc_slash gv_date lc_slash gv_year INTO gv_datab.
LOOP AT gi_c1_stritab INTO gw_itab.
PERFORM lf_bdc_dynpro USING 'SAPMV13A' '0100'.
PERFORM lf_bdc_field USING text-041
'RV13A-KSCHL'.
PERFORM lf_bdc_field USING text-040
'=ANTA'.
PERFORM lf_bdc_field USING 'RV13A-KSCHL'
'zhts'.
PERFORM lf_bdc_dynpro USING 'SAPLV14A' '0100'.
PERFORM lf_bdc_field USING text-041
'RV130-SELKZ(01)'.
PERFORM lf_bdc_field USING text-040
'=WEIT'.
PERFORM lf_bdc_dynpro USING 'SAPMV13A' '1317'.
PERFORM lf_bdc_field USING text-041
'KONP-VALTG(01)'.
PERFORM lf_bdc_field USING text-040
'=SICH'.
PERFORM lf_bdc_field USING 'KOMG-HLAND'
p_delcnt . "gw_itab-HLAND.
PERFORM lf_bdc_field USING 'KOMG-COIMP'
gw_itab-coimp.
PERFORM lf_bdc_field USING 'KOMG-HERKL(01)'
gw_itab-herkl.
PERFORM lf_bdc_field USING 'KONP-KBETR(01)'
gw_itab-kbetr.
PERFORM lf_bdc_field USING 'RV13A-DATAB(01)'
gv_datab.
PERFORM lf_bdc_field USING 'RV13A-DATBI(01)'
p_edate.
PERFORM lf_bdc_transaction USING gc_tcode.
REFRESH gi_bdcdata.
ENDLOOP.
ENDFORM. "gf_run_bdc
*************************FORM FILL_INTERNAL_TABLE**********************************
&**********************************************************************************
FORM gf_validation.
LOOP AT gi_t_stritab INTO gw_t_stritab.
gw_itab-hland = gw_t_stritab-hland.
gw_itab-sku = gw_t_stritab-sku.
gw_itab-description = gw_t_stritab-description.
gw_itab-herkl = gw_t_stritab-herkl.
gw_itab-coimp = gw_t_stritab-coimp.
gw_itab-coimp1 = gw_t_stritab-coimp1.
gw_itab-chdate = gw_t_stritab-chdate.
gw_itab-gstcode = gw_t_stritab-gstcode.
gw_itab-annex = gw_t_stritab-annex.
IF gw_t_stritab-mfn EQ space.
gw_itab-kbetr = gw_t_stritab-gpt.
ELSE.
gw_itab-kbetr = gw_t_stritab-mfn.
ENDIF.
gw_itab-ust = gw_t_stritab-ust.
APPEND gw_itab TO gi_stritab.
ENDLOOP.
CLEAR gi_t_stritab.
REFRESH gi_t_stritab.
CLEAR gi_hland_coimp.
REFRESH gi_hland_coimp.
SELECT land1 stawn "validation to check whether delivering country and import code is valid or not
FROM t604
INTO TABLE gi_hland_coimp
FOR ALL ENTRIES IN gi_stritab
WHERE land1 = gi_stritab-hland
AND stawn = gi_stritab-coimp.
IF sy-subrc NE 0.
WRITE:''.
ENDIF.
LOOP AT gi_stritab INTO gw_itab.
SORT gi_hland_coimp BY hland coimp. "sort table gi_hland_coimp
READ TABLE gi_hland_coimp INTO gw_hland_coimp WITH KEY hland = gw_itab-hland
coimp = gw_itab-coimp BINARY SEARCH. "read table gi_hland_coimp with key
IF sy-subrc NE 0. "if delivering country/import code combination is not valid
gw_e_stritab-hland = gw_itab-hland.
gw_e_stritab-sku = gw_itab-sku.
gw_e_stritab-description = gw_itab-description.
gw_e_stritab-herkl = gw_itab-herkl.
gw_e_stritab-coimp = gw_itab-coimp.
gw_e_stritab-chdate = gw_itab-chdate.
gw_e_stritab-gstcode = gw_itab-gstcode.
gw_e_stritab-annex = gw_itab-annex.
gw_e_stritab-kbetr = gw_itab-kbetr.
gw_e_stritab-ust = gw_itab-ust.
gw_e_stritab-error_desc = text-005.
APPEND gw_e_stritab TO gi_e_stritab. "append to error table
CONTINUE.
ELSE. "if delivering country/import code is valid
gw_c_stritab-hland = gw_itab-hland.
gw_c_stritab-sku = gw_itab-sku.
gw_c_stritab-description = gw_itab-description.
gw_c_stritab-herkl = gw_itab-herkl.
gw_c_stritab-coimp = gw_itab-coimp.
gw_c_stritab-chdate = gw_itab-chdate.
gw_c_stritab-gstcode = gw_itab-gstcode.
gw_c_stritab-annex = gw_itab-annex.
gw_c_stritab-kbetr = gw_itab-kbetr.
gw_c_stritab-ust = gw_itab-ust.
APPEND gw_c_stritab TO gi_c_stritab. "aappend to correct internal table
ENDIF.
ENDLOOP.
SELECT "validation to check whether the country of origin is valid
land1
FROM
t005
INTO
TABLE gi_herkl
FOR ALL ENTRIES IN gi_c_stritab
WHERE
land1 = gi_c_stritab-herkl.
IF sy-subrc NE 0.
WRITE:''.
ENDIF.
LOOP AT gi_c_stritab INTO gw_itab.
SORT gi_herkl BY herkl.
READ TABLE gi_herkl INTO gw_herkl WITH KEY herkl = gw_itab-herkl. "read table with key
IF sy-subrc NE 0. "if the country of origin is not valid
gw_e_stritab-hland = gw_itab-hland.
gw_e_stritab-sku = gw_itab-sku.
gw_e_stritab-description = gw_itab-description.
gw_e_stritab-herkl = gw_itab-herkl.
gw_e_stritab-coimp = gw_itab-coimp.
gw_e_stritab-chdate = gw_itab-chdate.
gw_e_stritab-gstcode = gw_itab-gstcode.
gw_e_stritab-annex = gw_itab-annex.
gw_e_stritab-kbetr = gw_itab-kbetr.
gw_e_stritab-ust = gw_itab-ust.
gw_e_stritab-error_desc = text-002.
APPEND gw_e_stritab TO gi_e_stritab. "append to error internal table
CONTINUE.
ELSE. "if the country of origin is valid
gw_c_stritab-hland = gw_itab-hland.
gw_c_stritab-sku = gw_itab-sku.
gw_c_stritab-description = gw_itab-description.
gw_c_stritab-herkl = gw_itab-herkl.
gw_c_stritab-coimp = gw_itab-coimp.
gw_c_stritab-chdate = gw_itab-chdate.
gw_c_stritab-gstcode = gw_itab-gstcode.
gw_c_stritab-annex = gw_itab-annex.
gw_c_stritab-kbetr = gw_itab-kbetr.
gw_c_stritab-ust = gw_itab-ust.
APPEND gw_c_stritab TO gi_c1_stritab. "append to correct internal table
ENDIF.
ENDLOOP.
CLEAR gi_herkl.
REFRESH gi_herkl.
CLEAR gi_c_stritab.
REFRESH gi_c_stritab.
ENDFORM. "gf_validation
&************************************************
************FORM gf_display_data.
&************************************************
FORM gf_display_data.
IF NOT gi_e_stritab IS INITIAL. "if the error table is not empty
LOOP AT gi_e_stritab INTO gw_e_stritab.
WRITE:/ gw_e_stritab-hland, 21 gw_e_stritab-sku,30 gw_e_stritab-description, 76 gw_e_stritab-herkl,88 gw_e_stritab-coimp,106 gw_e_stritab-chdate,126 gw_e_stritab-gstcode,135 gw_e_stritab-annex,176 gw_e_stritab-kbetr,195 gw_e_stritab-ust,
205 gw_e_stritab-error_desc.
ENDLOOP.
ULINE.
DESCRIBE TABLE gi_e_stritab LINES gv_line. "describe error internal table
WRITE:/ text-004, 55 gv_line.
CLEAR gi_e_stritab.
REFRESH gi_e_stritab.
DESCRIBE TABLE gi_stritab LINES gv_line1. "describe internal table containing legacy data
WRITE:/ text-003, 55 gv_line1.
IF p_test IS NOT INITIAL. "if the test button is checked
CLEAR gi_c1_stritab.
REFRESH gi_c1_stritab.
DESCRIBE TABLE gi_c1_stritab LINES gv_line2. "describe the no of records in the correct internal table
WRITE:/ text-026,55 gv_line2.
ELSE.
gv_line2 = gv_line1 - gv_line.
DESCRIBE TABLE gi_c1_stritab LINES gv_line2.
WRITE:/ text-026,55 gv_line2.
ENDIF.
CLEAR gv_line1.
CLEAR gv_line.
CLEAR gv_line2.
FREE:gi_e_stritab.
ENDIF.
ENDFORM. " display_data
&**************************************************************************************************&
FORM GF_HEADER
&**************************************************************************************************&
&----
*& Form GF_HEADER
&----
FORM gf_header.
NEW-LINE. " Dispalay the header section
ULINE.
WRITE:/ text-006.
WRITE:/ text-007.
SKIP 1.
WRITE: AT /1 'PROGRAM NAME:'(022),sy-repid,
'DATE :'(023),sy-datum,
AT 100 'TIME :'(024),sy-timlo.
WRITE: AT /1 'FILENAME:'(025),p_path.
ULINE.
SKIP 1.
WRITE:/ text-008.
WRITE:/ text-009.
WRITE:/ text-010.
WRITE: AT 23 text-031.
WRITE: AT 33 text-032.
WRITE: AT 66 text-033.
WRITE: AT 87 text-034.
WRITE: AT 105 text-035.
WRITE: AT 123 text-036.
WRITE: AT 153 text-037.
WRITE: AT 173 text-038.
WRITE: AT 193 text-039.
WRITE: AT 213 text-021.
ULINE.
NEW-LINE.
NEW-LINE.
ENDFORM. " HEADER
&----
*& Form GF_BDC_RESULT
&----
FORM gf_bdc_result . "Displays the how many records loaded in SAP
LOOP AT gi_msg INTO gv_msg.
WRITE:/ gv_msg.
ENDLOOP.
LOOP AT gi_c1_stritab INTO gw_c_stritab.
WRITE:/ gw_c_stritab-hland, 21 gw_c_stritab-sku,33 gw_c_stritab-description, 70 gw_c_stritab-herkl,86 gw_c_stritab-coimp,106 gw_c_stritab-chdate,126 gw_c_stritab-gstcode,146 gw_c_stritab-annex,173 gw_c_stritab-kbetr,194 gw_c_stritab-ust.
ENDLOOP.
ULINE.
DESCRIBE TABLE gi_msg LINES gv_line1.
gv_line1 = gv_line1 + gv_line.
WRITE:/ text-026, 55 gv_no_succs.
WRITE:/ text-027, 55 gv_line1.
CLEAR: gv_line1,gv_line.
DESCRIBE TABLE gi_stritab LINES gv_line1.
WRITE:/ text-003, 55 gv_line1.
CLEAR gi_stritab.
REFRESH gi_stritab.
ENDFORM. " BDC_RESULT
*******end of code****************************************************************
check this code hope this answers ur query!!!plss reward if useful!!
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |