2007 Jul 06 7:19 AM
hi all,
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
INPUT =
IMPORTING
OUTPUT =
i need to convert it_makt-matnr
what will be the INPUT and OUTPUT for the FM
hi all,
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
INPUT =
IMPORTING
OUTPUT =
i need to convert it_makt-matnr
what will be the INPUT and OUTPUT for the FM
2007 Jul 06 7:21 AM
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
INPUT = it_makt-matnr
IMPORTING
OUTPUT = it_makt-matnr.Input will be 123
Output will be 000000000000000123
This fm will add leading ZEROS to the material number because when u query on MAKT with MATNR as just 123 you wll not be getting any values, so u should use this conversion exit to add leading zeros.
Regards
Gopi
2021 Apr 13 8:30 AM
Hello. In which step of LSMW with Bapi can I use this function?
Thank you in advance.
2007 Jul 06 7:23 AM
Hi ,
it will be
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
INPUT = it_makt-matnr
IMPORTING
OUTPUT = it_makt-matnr
Regards,
Atish
2007 Jul 06 7:46 AM
thanks atish,
see my code...am still not getting desired out put with this..
note: matnr = mat_test10 spras = english a record is there in MAKT (i created)
and file contains: matnr maktx
mat_test10 eng_disc
,, 11 disc
,, 12 disc
so plz check this code
tables: MAKT.
data: BEGIN OF it_makt OCCURS 0,
matnr LIKE maKT-matnr,
maktx LIKE makt-maktx,
END OF it_makt.
data: process_tab_struct_tmp like IT_MAKT.
field-symbols: <fs1>.
DATA : excel_tab TYPE TABLE OF ALSMEX_TABLINE WITH HEADER LINE.
data: it_bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
PARAMETER P_FILE LIKE RLGRAP-FILENAME.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
PERFORM F4_FILE.
perform download_file.
*********
start-of-selection.
LOOP AT EXCEL_TAB.
assign component excel_tab-col of structure
process_tab_struct_tmp to <fs1>.
<fs1> = excel_tab-value.
at end of row.
move-corresponding: process_tab_struct_tmp to IT_MAKT.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
INPUT = it_makt-matnr
IMPORTING
OUTPUT = it_makt-matnr.
append IT_MAKT.
endat.
ENDLOOP.
LOOP AT it_makt.
select single * from makt where matnr = it_makt-matnr and spras = 'E'.
if sy-subrc = 0.
write:/ makt-matnr, makt-maktx.
else.
write:/ 'Error!'.
endif.
ENDLOOP.
clear it_makt[].
free it_makt.
&----
*& Form F4_FILE
&----
text
----
--> p1 text
<-- p2 text
----
FORM F4_FILE .
DATA:
lt_filetable TYPE filetable,
lf_rc TYPE i.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
multiselection = abap_false
CHANGING
file_table = lt_filetable
rc = lf_rc
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
DISPLAY LIKE 'E'
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.
Number of selected filed must be equal to one.
CHECK lf_rc = 1.
Access selected file
DATA:
ls_file TYPE file_table.
READ TABLE lt_filetable INTO ls_file INDEX 1.
CHECK sy-subrc = 0.
P_file = ls_file-filename.
*CALL FUNCTION 'F4_FILENAME'
*EXPORTING
*PROGRAM_NAME = 'ZMAMASS_MATERIAL_DISC_UPADTION'
*DYNPRO_NUMBER = '1000'
*FIELD_NAME = 'P_FILE'
*IMPORTING
*FILE_NAME = P_FILE.
*
ENDFORM. " F4_FILE
&----
*& Form download_file
&----
text
----
--> p1 text
<-- p2 text
----
FORM download_file .
data: fname type localfile.
fname = p_file.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = fname
I_BEGIN_COL = 1
I_BEGIN_ROW = 2
I_END_COL = 2
I_END_ROW = 4
TABLES
INTERN = EXCEL_TAB
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endform.
2007 Jul 06 7:50 AM
hi,
There seems nothing wrong in the code.
Change this.
select single * from makt where matnr = it_makt-matnr and spras = <b>sy-langu</b>.
Also can you just in the debugging let me know the value of it_makt-matnr before and after this FM.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
INPUT = it_makt-matnr
IMPORTING
OUTPUT = it_makt-matnr.
Regards,
Atish
2007 Jul 06 7:59 AM
thx..will test it with sy-langu
but my require ment is spras = english, coz they may enter with swedish as sy-langu
2014 Aug 18 9:03 AM
1.Remove the language field spras = 'E'.
2.Convert Maktx field aslo................
LOOP AT it_makt.
select single * from makt where matnr = it_makt-matnr and spras = 'E'.
Endloop.
2007 Jul 06 7:35 AM
Hi,
DATA : it_makt TYPE STANDARD TABLE OF makt WITH HEADER LINE.
DATA : lv_matnr TYPE makt-matnr.
LOOP AT it_makt.
lv_matnr = it_makt-matnr.
CALL FUNCTION 'CONVERSION_EXIT_MATN2_INPUT'
EXPORTING
input = lv_matnr
IMPORTING
output = lv_matnr.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDLOOP.
Input = 786.
Output = 0000000786.
Pls reward points.
Regards,
Ameet
Message was edited by:
Ameet Jassani
2014 Aug 18 8:00 AM
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = matnr
IMPORTING
OUTPUT = matnr1
* EXCEPTIONS
* LENGTH_ERROR = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
new value will come in matnr1....
2014 Aug 18 8:57 AM
Hi David Use these code
TYPE-POOLS: truxs.
TYPES: BEGIN OF ty_upld,
mandt TYPE mandt,
matnr TYPE c LENGTH 40,
werks TYPE c LENGTH 40,
pname TYPE c LENGTH 70,
pdate TYPE c LENGTH 40,
pquan TYPE c LENGTH 40,
END OF ty_upld.
TYPES: BEGIN OF ty_dwd,
mandt TYPE mandt,
matnr TYPE c LENGTH 40,
werks TYPE c LENGTH 40,
pname TYPE c LENGTH 40,
pdate TYPE c LENGTH 40,
pquan TYPE c LENGTH 40,
msg TYPE string,
END OF ty_dwd.
DATA: gt_excel TYPE STANDARD TABLE OF ty_upld,
gt_final TYPE STANDARD TABLE OF ty_dwd,
gt_success TYPE STANDARD TABLE OF ty_dwd,
gt_error TYPE STANDARD TABLE OF ty_dwd.
SELECTION-SCREEN: BEGIN OF BLOCK 001 WITH FRAME TITLE text-001.
PARAMETERS: p_upload TYPE rlgrap-filename,
p_dwnld TYPE rlgrap-filename," DEFAULT 'c:\temp\cei_log.xls',
p_head AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN: END OF BLOCK 001.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_upload.
PERFORM load_file CHANGING p_upload.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_dwnld.
PERFORM load_file CHANGING p_dwnld.
*PERFORM dump.
START-OF-SELECTION.
PERFORM text_convert_xls_to_sap.
PERFORM data_retreival.
PERFORM downlaod.
.
*&---------------------------------------------------------------------*
*& Form LOAD_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_P_FILE text
*----------------------------------------------------------------------*
FORM load_file CHANGING cp_file TYPE rlgrap-filename.
DATA: lt_file TYPE filetable,
ls_file TYPE file_table,
lv_rc TYPE i.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
default_filename = '*.XLS'
file_filter = '(*.xlsx)|*.XLSX|'
CHANGING
file_table = lt_file
rc = lv_rc
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc <> 0.
ELSE.
READ TABLE lt_file INTO ls_file INDEX 1.
IF sy-subrc IS INITIAL.
cp_file = ls_file-filename.
ENDIF.
ENDIF.
ENDFORM. " LOAD_FILE
*&---------------------------------------------------------------------*
*& Form TEXT_CONVERT_XLS_TO_SAP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM text_convert_xls_to_sap .
DATA: it_raw TYPE truxs_t_text_data.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_line_header = 'X'
i_tab_raw_data = it_raw " WORK TABLE
i_filename = p_upload
TABLES
i_tab_converted_data = gt_excel[] "ACTUAL DATA
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
ENDFORM. " TEXT_CONVERT_XLS_TO_SAP
*&---------------------------------------------------------------------*
*& Form DATA_RETREIVAL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM data_retreival .
DATA: ls_excel TYPE ty_upld,
ls_excel1 TYPE zraw,
ls_error TYPE ty_dwd,
ls_success TYPE ty_dwd,
lv_total TYPE sy-tfill,
lv_success TYPE sy-tfill,
lv_error TYPE sy-tfill,
lv_error_c TYPE char20,
lv_success_c TYPE char20,
lv_total_c TYPE char20,
lv_date(10) TYPE c.
LOOP AT gt_excel INTO ls_excel.
ls_excel1-matnr = ls_excel-matnr.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = ls_excel1-matnr
IMPORTING
output = ls_excel1-matnr
EXCEPTIONS
length_error = 1
OTHERS = 2.
ls_excel1-werks = ls_excel-werks.
ls_excel1-pname = ls_excel-pname.
TRANSLATE ls_excel1-pname TO UPPER CASE.
lv_date = ls_excel-pdate.
REPLACE ALL OCCURRENCES OF '.' IN lv_date WITH ''.
CONCATENATE lv_date+4(4) lv_date+2(2) lv_date+0(2) INTO lv_date.
ls_excel1-pdate = lv_date.
ls_excel1-pquan = ls_excel-pquan .
MODIFY zraw FROM ls_excel1.
IF sy-subrc NE 0.
MOVE-CORRESPONDING ls_excel TO ls_error.
ls_error-msg = 'Error'.
APPEND ls_error TO gt_error.
CLEAR: ls_error.
ELSE.
MOVE-CORRESPONDING ls_excel TO ls_success.
ls_success-msg = 'Success'.
APPEND ls_success TO gt_success.
CLEAR: ls_success.
ENDIF.
ENDLOOP.
DESCRIBE TABLE gt_success LINES lv_success.
DESCRIBE TABLE gt_error LINES lv_error.
lv_total = lv_success + lv_error.
lv_error_c = lv_error.
lv_success_c = lv_success.
lv_total_c = lv_total.
CONDENSE : lv_error_c, lv_success_c, lv_total_c.
*REPLACE ALL OCCURRENCES OF '.' in ls_success-PQUAN 'c
* ls_success-mandt = 'Client'.
ls_success-matnr = 'Material Number'.
ls_success-werks = 'Plant'.
ls_success-pname = 'Plan Name'.
ls_success-pdate = 'Plan Date'.
ls_success-pquan = 'Req quantity' .
INSERT ls_success INTO gt_error INDEX 1.
CLEAR ls_success.
APPEND LINES OF gt_error TO gt_final.
APPEND LINES OF gt_success TO gt_final.
* **Output Details*****
WRITE: /01 'Program Name'(114),
27 ':',
30 sy-repid,
/01 'User-Id'(115),
27 ':',
30 sy-uname,
82 sy-datum DD/MM/YY,
92 sy-uzeit.
ULINE.
WRITE: / 'TOTAL INPUT RECORDS READ'(116), 28 lv_total_c.
WRITE: / 'TOTAL RECORDS SUCCESS'(117), 28 lv_success_c.
WRITE: / 'TOTAL RECORDS ERROR'(118), 28 lv_error_c.
ENDFORM. " DATA_RETREIVAL
*&---------------------------------------------------------------------*
*& Form DOWNLAOD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM downlaod .
DATA: lv_file TYPE string.
lv_file = p_dwnld.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = lv_file
* filetype = 'ASC'
write_field_separator = 'X'
CHANGING
data_tab = gt_final.
IF sy-subrc <> 0.
ENDIF.
ENDFORM. " DOWNLAOD
2014 Aug 18 12:30 PM
Dear,
We use " conversion_exit_mat1_Input ", to add zero padding to material number.
We use " Conversion_exit_mat1_output " to remove zero padding from you material number.
In Some scenarios, when we fetch data from db table with select statement and with some conditions, the sy-subrc value is 4. So if u ll check entries in db table u can find that material.so in such cases we have to use conversion exit.
For any field if u want the conversion exit them find that field in table then double click on the data element and thn domain.there u ll find the appropriate conversion_exist provided by sap.
So u have to use that one by clicking on pattern button in program.
So that u ll get ur correct data. for that we we have to pass the field in exporting parameter and fm will give u with padding or without padding value in importing parameter.
lets one example...
select * from mara into it_mara where <Condition>.
Now... loop at it_mara into ls_mara.
FM conversion_exit_mat1_input
exporting
input = ls_mara-matnr
importing
output = ls_mara-matnr
endloop.
thn modify ur lt_mara table to modify with new value.
Also if u ll use field symbol then no need for modify statement.
chk if i ll help u and for any further issue plz replay back
Thanks & Regards,
Ajit Sarangi