Calling Function Module for upper case to lower case in Transformation
Hi all,
We have the data load happening everyday for the Account Receivables data. The DSO activation is failing because of the invalid characters. It gives the messages as below
"Value 'bdmg0808dm' (hex. '620064006D006700300038003000380064006D00') of characteristic ZINVNUM contains invalid characters"
We understood that the character ZINVNUM is maintained only for uppercase letter wherein the lower case check box is not ticked. We have a function module which is build within BI which can be used to permit non permitted characters including space. Just want to know how can I call this function module in a transformation and which is the best option to call the function module(start routine/end routine).
Regards
Vijay
You can use statement in end routine to convert text to upper case. No need of calling any function module. Just loop through records of RESULT_PACKAGE and for that particular field convert text using below statement.
LOOP AT RESULT_PACKAGE.
TRANSLATE RESULT_PACAKGE-/BIC/ZNAME TO UPPER CASE.
ENDLOOP.
Edited by: ABHIJIT TEMBHEKAR on Nov 14, 2008 2:22 PM
Similar Messages
-
Function modules for the following
Hi,
I want to know the function modules for the following purposes.
1) Check whether a date is valid or not
2) Calculate the no of days between two dates.
Expecting an early response.
Thanks n Regards,
AmitHi,
PARAMETERS: p_list LIKE t009b-bumon AS LISTBOX
VISIBLE LENGTH 11 OBLIGATORY ,
p_list1 LIKE t009b-bdatj OBLIGATORY.
SELECTION-SCREEN POSITION POS_HIGH.
PARAMETERS: p_list2 LIKE t009b-bumon AS LISTBOX
VISIBLE LENGTH 11 OBLIGATORY,
p_list3 LIKE t009b-bdatj OBLIGATORY.
Calling Function Module for calculating no of days between the
selected period
CALL FUNCTION 'NUMBER_OF_DAYS_PER_MONTH_GET'
EXPORTING
par_month = p_list
par_year = p_list1
IMPORTING
par_days = ws_n_days.
CALL FUNCTION 'NUMBER_OF_DAYS_PER_MONTH_GET'
EXPORTING
par_month = p_list2
par_year = p_list3
IMPORTING
par_days = ws_n_days1.
For Concatenating the month and year into the date format
CONCATENATE p_list1 p_list ws_i INTO ws_c_date1.
CONCATENATE p_list3 p_list2 ws_n_days1 INTO ws_c_date2.
date = ws_c_date1 - ws_c_date2.
In the above sample code the selection screen has month and year as input.
Also check this link
http://www.sapdevelopment.co.uk/tips/date/datehome.htm
Check FM
<b>RP_CALC_DATE_IN_INTERVAL</b> Add/subtract years/months/days from a date
<b>SD_DATETIME_DIFFERENCE</b> Give the difference in Days and Time for 2 dates
<b>Also for checking valid date:</b>
U can specify the date field as
Select-options: s_date like likp-date(similar to ur requirement)
This itself ceck for the valid date no seperate validation needed.
Thanks & Regards,
Judith. -
Function Module for Translation of text from Lower to Upper Case
Hi All,
Can any one give me function module for translation of text from lower to upper case.
If we use Translate statement for the program in the Extended Syntax check it is giving error.
Thanks in advance.
Regards,
srinivasHi Srinivas,
You can use any of the Function Modules below.
AIPC_CONVERT_TO_UPPERCASE
2054_TRANSLATE_2_UPPERCASE
HR_99S_CONV_UPPER_CASE
Please reward if useful.
regards,
Raj -
How to call function module in BPS for step by step execution.??
Hi All,
I used the Exit(function module) in char relation ship for derivation,combination check and proposal defined the source char and target char and function module for Derivation,every thing working fine.But how can i call the function module once i entered the data in my planning layout.Just i need to validate my function module working fine or not???
How can i debug the function modules in BPS ,because we are using the exits in different places,please any one can explain each place how we can do the debug??Where we have to put the break points?? .
Just give the path i can try in my system BPS 4.0 version we are using.
Note:I know how to debug the function module only.but I don't know Using BPS screen's .
Thanks,Hi ,
Thanks for replies about my question??.
If i am using the exit in my char relation ship how can i debugg that exit???
if i am using BPS0 how to do it???If i am using BPS_WB how to do it??
Case1.Variable (type Exit) I known how to do debugg this one in BPS0 but i'm not sure in BPS_WB??
Case2:Char Relation Ship(Type Exit) how to do in BPS0 and BPS_WB??.
Thanks. -
Call Function not Generating Function Module for Smartform
Hi Gurus,
We have a work copy print program use to print deliveries (smartforms). This program works fine in Production but right now we are doing some testing and I found out that when we run this program in QUALITY environtment, it shortdumps with error saying "Function Module Not Found"
Basically when it gets to the Function Module "SSF_FUNCTION_MODULE_NAME", it could not generate any function module for the form it Sy-Subrc = 2 Exception meaning NO_FUNCTION_MODULE.
The problem is this only happens in our QUALITY environment.I compare the function module in the 2 systems, there was not diff as this is a Standard SAP module. I passed diff smartforms we have in QUALITY through the FM and it will not generating any FM for any of them. So this is not an error from the smartforms, bcos all the same smartforms generates FM in Prod.
So what I did next is to Debug the FM "SSF_FUNCTION_MODULE_NAME" in the 2 systems to see where the diff is coming from. I noticed 2 views that the FM is using, they are STXFADM and D010SINF . So on the Production system, STXFADM-LASTDATE and D010SINF-UDAT fields are the same value, so it generates the FM. On the QUALITY systems, the values are different hence it skips the code to generate the FM.
Thanks Guys.
Points will greatly be awarded for this.Please guys, help me look into this, I really need a solution fast.
Thanks -
Function Module for sending an Attachment
Not able to find the Function Module for sending an Attachment to the email ids.
Please help.Hi bala,
1. There is some trick involved in attachment
in the binary files.
2. I have made a program (and it works fantastic)
ONLY 6 LINES FOR EMAILING
BELIEVE ME
ITS A FANTASTIC PROGRAM.
IT WILL WORK LIKE OUTLOOK EXPRESS !
3. The user is provided with
a) file name
b) email address to send mail
and it sends ANY FILE (.xls,.pdf .xyz..)
Instantaneously !
4. Make two things first :
1. Include with the name : ZAMI_INCLFOR_MAIL
2. Report with the name : ZAM_TEMP147 (any name will do)
3. Activate both and execute (2)
4. After providing filename, email adress
5. Code for Include :
10.08.2005 Amit M - Created
Include For Mail (First Req F16)
Modification Log
Data
DATA: docdata LIKE sodocchgi1,
objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objhex LIKE solix OCCURS 10 WITH HEADER LINE,
reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
DATA: tab_lines TYPE i,
doc_size TYPE i,
att_type LIKE soodk-objtp.
DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
FORM
FORM ml_customize USING objname objdesc.
Clear Variables
CLEAR docdata.
REFRESH objpack.
CLEAR objpack.
REFRESH objhead.
REFRESH objtxt.
CLEAR objtxt.
REFRESH objbin.
CLEAR objbin.
REFRESH objhex.
CLEAR objhex.
REFRESH reclist.
CLEAR reclist.
REFRESH listobject.
CLEAR listobject.
CLEAR tab_lines.
CLEAR doc_size.
CLEAR att_type.
Set Variables
docdata-obj_name = objname.
docdata-obj_descr = objdesc.
ENDFORM. "ml_customize
FORM
FORM ml_addrecp USING preceiver prec_type.
CLEAR reclist.
reclist-receiver = preceiver.
reclist-rec_type = prec_type.
APPEND reclist.
ENDFORM. "ml_customize
FORM
FORM ml_addtxt USING ptxt.
CLEAR objtxt.
objtxt = ptxt.
APPEND objtxt.
ENDFORM. "ml_customize
FORM
FORM ml_prepare USING bypassmemory whatatt_type whatname.
IF bypassmemory = ''.
Fetch List From Memory
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = listobject
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'LIST_FROM_MEMORY'.
ENDIF.
CALL FUNCTION 'TABLE_COMPRESS'
IMPORTING
COMPRESSED_SIZE =
TABLES
in = listobject
out = objbin
EXCEPTIONS
OTHERS = 1
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'TABLE_COMPRESS'.
ENDIF.
ENDIF.
Header Data
Already Done Thru FM
Main Text
Already Done Thru FM
Packing Info For Text Data
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'TXT'.
APPEND objpack.
Packing Info Attachment
att_type = whatatt_type..
DESCRIBE TABLE objbin LINES tab_lines.
READ TABLE objbin INDEX tab_lines.
objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = att_type.
objpack-obj_name = 'ATTACHMENT'.
objpack-obj_descr = whatname.
APPEND objpack.
Receiver List
Already done thru fm
ENDFORM. "ml_prepare
FORM
FORM ml_dosend.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = docdata
put_in_outbox = 'X'
commit_work = 'X' "used from rel. 6.10
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
CONTENTS_HEX = objhex
OBJECT_PARA =
object_parb =
receivers = reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8
IF sy-subrc <> 0.
MESSAGE ID 'SO' TYPE 'S' NUMBER '023'
WITH docdata-obj_name.
ENDIF.
ENDFORM. "ml_customize
FORM
FORM ml_spooltopdf USING whatspoolid.
DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
Call Function
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = whatspoolid
TABLES
pdf = pdf
EXCEPTIONS
err_no_otf_spooljob = 1
OTHERS = 12.
Convert
PERFORM doconv TABLES pdf objbin.
ENDFORM. "ml_spooltopdf
FORM
FORM doconv TABLES
mypdf STRUCTURE tline
outbin STRUCTURE solisti1.
Data
DATA : pos TYPE i.
DATA : len TYPE i.
Loop And Put Data
LOOP AT mypdf.
pos = 255 - len.
IF pos > 134. "length of pdf_table
pos = 134.
ENDIF.
outbin+len = mypdf(pos).
len = len + pos.
IF len = 255. "length of out (contents_bin)
APPEND outbin.
CLEAR: outbin, len.
IF pos < 134.
outbin = mypdf+pos.
len = 134 - pos.
ENDIF.
ENDIF.
ENDLOOP.
IF len > 0.
APPEND outbin.
ENDIF.
ENDFORM. "doconv
CODE FOR PROGRAM
5.
REPORT zam_temp147 .
INCLUDE zami_inclfor_mail.
DATA
DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
DATA : file_name TYPE string.
data : path like PCFILE-PATH.
data : extension(5) type c.
data : name(100) type c.
SELECTION SCREEN
PARAMETERS : receiver TYPE somlreci1-receiver lower case.
PARAMETERS : p_file LIKE rlgrap-filename
OBLIGATORY.
AT SELECTION SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CLEAR p_file.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_file.
START-OF-SELECTION
START-OF-SELECTION.
PERFORM ml_customize USING 'Tst' 'Testing'.
PERFORM ml_addrecp USING receiver 'U'.
PERFORM upl.
PERFORM doconv TABLES itab objbin.
PERFORM ml_prepare USING 'X' extension name.
PERFORM ml_dosend.
SUBMIT rsconn01
WITH mode EQ 'INT'
AND RETURN.
FORM
FORM upl.
file_name = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file_name
filetype = 'BIN'
TABLES
data_tab = itab
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.
path = file_name.
CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
EXPORTING
complete_filename = path
CHECK_DOS_FORMAT =
IMPORTING
DRIVE =
EXTENSION = extension
NAME = name
NAME_WITH_EXT =
PATH =
EXCEPTIONS
INVALID_DRIVE = 1
INVALID_EXTENSION = 2
INVALID_NAME = 3
INVALID_PATH = 4
OTHERS = 5
ENDFORM. "upl
regards,
amit m. -
Hi all,
Is there any Z function modules for OLE, which will download the data directly to Excel with 2 sheets.
Regards,
ShaliniHi Shalini Reddy
there is no FM but code is there... u can see...
*& Report YOLE_FOR_EXCEL
REPORT yole_for_excel.
*REPORT ZTEST_BYW.
OLE specific include file
INCLUDE ole2incl.
INCLUDE excel__c.
data definitions of OLE objects with type ole2_object
PARAMETERS: p_filenm(80) LOWER CASE OBLIGATORY
DEFAULT 'd:\temp\report_tsl.xls'.
DATA: g_tmp_workbook TYPE ole2_object.
DATA: g_tmp_worksheets TYPE ole2_object.
DATA: g_tmp_worksheet1 TYPE ole2_object.
DATA: g_tmp_worksheet2 TYPE ole2_object.
DATA: g_pc_template LIKE rcgfiletr-ftappl
VALUE 'd:\temp\mmr_rpt_tsl_tmp.xls'.
DATA: g_excel TYPE ole2_object.
DATA: g_workbooks TYPE ole2_object.
DATA: g_workbook TYPE ole2_object.
DATA: g_worksheets TYPE ole2_object.
DATA: g_worksheet TYPE ole2_object.
DATA: g_cell TYPE ole2_object.
DATA: g_cell1 TYPE ole2_object.
DATA: g_cell2 TYPE ole2_object.
DATA: g_cellrange TYPE ole2_object.
DATA: g_font TYPE ole2_object.
DATA: g_interior TYPE ole2_object.
DATA: g_borders TYPE ole2_object.
DATA: g_first_ws VALUE 'Y'.
DATA: g_row TYPE i.
DATA: g_col TYPE i.
definition of loop counter
DATA: i TYPE i VALUE '5'.
DATA: BEGIN OF t_sheet1 OCCURS 1,
col1(10),
col2(20),
END OF t_sheet1.
DATA: BEGIN OF t_sheet2 OCCURS 1,
col1(10),
col2(20),
END OF t_sheet2.
START-OF-SELECTION.
PERFORM prepare_data.
PERFORM download_to_excel.
END-OF-SELECTION.
call method of excel 'QUIT'.
it is now possible to leave the EXCEL application
remark: you have to go to the EXCEL application and answer the
popup dialog screen
*& Form PREPARE_DATA
FORM prepare_data.
t_sheet1-col1 = 'A1'.
t_sheet1-col2 = 'A2'.
APPEND t_sheet1.
t_sheet1-col1 = 'B1'.
t_sheet1-col2 = 'B2'.
APPEND t_sheet1.
t_sheet2-col1 = 'Y1'.
t_sheet2-col2 = 'Y2'.
APPEND t_sheet2.
t_sheet2-col1 = 'Z1'.
t_sheet2-col2 = 'Z2'.
APPEND t_sheet2.
ENDFORM. " PREPARE_DATA
*& Form DOWNLOAD_TO_EXCEL
FORM download_to_excel.
PERFORM open_excel.
PERFORM add_worksheet1.
PERFORM add_worksheet2.
PERFORM open_template_file.
PERFORM close_excel.
WRITE: / 'End of program'.
ENDFORM. " DOWNLOAD_TO_EXCEL
*& Form FILL_CELL
*& FORM routine, which fills the specified cell in the EXCEL sheet
*& with the given value
FORM fill_cell USING i_row TYPE i
i_col TYPE i
i_value
i_fontbold
i_digit
i_wraptext
i_horizon_align
i_vertical_align.
DATA: l_str TYPE string.
CALL METHOD OF g_excel 'CELLS' = g_cell
EXPORTING #1 = i_row
#2 = i_col.
SET PROPERTY OF g_cell 'VALUE' = i_value.
IF i_fontbold = 'X'.
GET PROPERTY OF g_cell 'Font' = g_font.
SET PROPERTY OF g_font 'Bold' = 1.
ENDIF.
IF NOT i_wraptext IS INITIAL.
SET PROPERTY OF g_cell 'WrapText' = 1.
ENDIF.
IF NOT i_horizon_align IS INITIAL.
IF i_horizon_align = 'L'.
SET PROPERTY OF g_cell 'HorizontalAlignment' = xlleft.
ELSEIF i_horizon_align = 'R'.
SET PROPERTY OF g_cell 'HorizontalAlignment' = xlright.
ELSEIF i_horizon_align = 'C'.
SET PROPERTY OF g_cell 'HorizontalAlignment' = xlcenter.
ENDIF.
ENDIF.
IF NOT i_vertical_align IS INITIAL.
IF i_vertical_align = 'T'.
SET PROPERTY OF g_cell 'VerticalAlignment' = xltop.
ELSEIF i_vertical_align = 'B'.
SET PROPERTY OF g_cell 'VerticalAlignment' = xlbottom.
ELSEIF i_vertical_align = 'C'.
SET PROPERTY OF g_cell 'VerticalAlignment' = xlcenter.
ENDIF.
ENDIF.
To set number format for cell
IF i_digit <> ''.
IF i_value IS INITIAL AND i_digit <> '%'.
SET PROPERTY OF g_cell 'VALUE' = ''.
ELSE.
Set number format for cell with number
IF i_digit = '1'.
SET PROPERTY OF g_cell 'NumberFormat' = '#,###.0 '.
ELSEIF i_digit = '2'.
SET PROPERTY OF g_cell 'NumberFormat' = '#,##0.00 '.
ELSEIF i_digit = '%'.
SET PROPERTY OF g_cell 'NumberFormat' = '#,##0.00% '.
ELSE.
SET PROPERTY OF g_cell 'NumberFormat' = '#,### '.
ENDIF.
ENDIF.
ENDIF.
ADD 1 TO i_col.
ENDFORM. "FILL_CELL
*& Form OPEN_EXCEL
FORM open_excel.
DATA: l_cnt TYPE i.
create object excel of OLE class 'EXCEL.APPLICATION'
CREATE OBJECT g_excel 'EXCEL.APPLICATION'.
CALL METHOD OF g_excel 'WORKBOOKS' = g_workbooks.
CALL METHOD OF g_workbooks 'ADD' = g_workbook.
GET PROPERTY OF g_workbook 'Worksheets' = g_worksheets.
GET PROPERTY OF g_excel 'ACTIVESHEET' = g_worksheet.
SET PROPERTY OF g_excel 'DISPLAYALERTS' = 0.
GET PROPERTY OF g_worksheets 'Count' = l_cnt.
l_cnt = l_cnt - 1.
Delete unwanted worksheets
DO l_cnt TIMES.
GET PROPERTY OF g_excel 'ACTIVESHEET' = g_worksheet.
CALL METHOD OF g_worksheet 'DELETE'.
ENDDO.
ENDFORM. " OPEN_EXCEL
*& Form CLOSE_EXCEL
FORM close_excel.
SET PROPERTY OF g_excel 'VISIBLE' = 1.
CALL METHOD OF g_workbook 'SAVEAS'
EXPORTING #1 = p_filenm.
quit Excel and free all OLE objects
call method of g_excel 'QUIT'.
FREE OBJECT g_interior.
FREE OBJECT g_borders.
FREE OBJECT g_font.
FREE OBJECT g_cell.
FREE OBJECT g_cell1.
FREE OBJECT g_cell2.
FREE OBJECT g_cellrange.
FREE OBJECT g_excel.
FREE OBJECT g_workbooks.
FREE OBJECT g_workbook.
FREE OBJECT g_worksheets.
FREE OBJECT g_worksheet.
ENDFORM. " CLOSE_EXCEL
*& Form ADD_WORKSHEET
FORM add_worksheet USING i_name.
Add new worksheet
IF g_first_ws <> 'N'.
g_first_ws = 'N'.
GET PROPERTY OF g_excel 'ACTIVESHEET' = g_worksheet.
ELSE.
CALL METHOD OF g_worksheets 'Add' = g_worksheet.
ENDIF.
SET PROPERTY OF g_worksheet 'NAME' = i_name.
g_row = 1.
g_col = 1.
ENDFORM. " ADD_WORKSHEET
*& Form ADD_WORKSHEET1
FORM add_worksheet1.
PERFORM add_worksheet USING 'Test 1'.
fill line in EXCEL sheet with headerlines of table columns
g_col = 1.
PERFORM fill_cell USING g_row g_col 'My First Worksheet' 'X' ''
PERFORM merge_cell USING g_row 1 g_row 4.
PERFORM set_border USING g_row 1 g_row 4 4 ''.
ADD 1 TO g_row.
g_col = 1.
PERFORM fill_cell USING g_row g_col 'ID'(001) 'X' '' '' '' ''.
PERFORM fill_cell USING g_row g_col 'Name'(002) 'X' '' '' '' ''.
PERFORM fill_cell USING g_row g_col 'Telephon'(003) 'X' '' '' '' ''.
PERFORM fill_cell USING g_row g_col 'Rabatt'(004) 'X' '' '' '' ''.
loop at customr table and print values into EXCEL sheet
ADD 1 TO g_row.
LOOP AT t_sheet1.
g_col = 1.
PERFORM fill_cell USING g_row g_col t_sheet1-col1 '' '' '' '' ''.
PERFORM fill_cell USING g_row g_col t_sheet1-col2 '' '' '' '' ''.
ADD 1 TO g_row.
ENDLOOP.
g_col = 4.
PERFORM set_border USING 1 1 g_row g_col '' 4.
ENDFORM. " ADD_WORKSHEET1
*& Form ADD_WORKSHEET2
FORM add_worksheet2.
PERFORM add_worksheet USING 'Test 2'.
fill line in EXCEL sheet with headerlines of table columns
g_col = 1.
PERFORM fill_cell USING g_row g_col 'My Second Worksheet' 'X' ''
PERFORM merge_cell USING g_row 1 g_row 4.
PERFORM set_border USING g_row 1 g_row 4 1 'X'.
PERFORM set_color USING g_row 1 g_row 4 'LT'.
ADD 1 TO g_row.
g_col = 1.
PERFORM fill_cell USING g_row g_col 'ID'(001) 'X' '' '' '' ''.
PERFORM fill_cell USING g_row g_col 'Name'(002) 'X' '' '' '' ''.
PERFORM fill_cell USING g_row g_col 'Telephon'(003) 'X' '' '' '' ''.
PERFORM fill_cell USING g_row g_col 'Rabatt'(004) 'X' '' '' '' ''.
loop at customr table and print values into EXCEL sheet
ADD 1 TO g_row.
LOOP AT t_sheet2.
g_col = 1.
PERFORM fill_cell USING g_row g_col t_sheet2-col1 '' '' '' '' ''.
PERFORM fill_cell USING g_row g_col t_sheet2-col2 '' '' '' '' ''.
ADD 1 TO g_row.
ENDLOOP.
g_col = 4.
PERFORM set_border USING 1 1 g_row g_col 2 'X'.
ADD 4 TO g_row.
g_col = 1.
PERFORM fill_cell USING g_row g_col 'This is a wrap text' 'X' ''
'X' 'C' 'T'.
PERFORM fill_cell USING g_row g_col 'Vertical - Bottom' 'X' ''
'' 'L' 'T'.
ADD 4 TO g_row.
g_col = 1.
PERFORM fill_cell USING g_row g_col 'Amount 1' 'X' '' '' '' ''.
PERFORM fill_cell USING g_row g_col '100.04' '' 'X' '' '' ''.
ADD 1 TO g_row.
g_col = 1.
PERFORM fill_cell USING g_row g_col 'Amount 2' 'X' '' '' '' ''.
PERFORM fill_cell USING g_row g_col '200.01' '' 'X' '' '' ''.
ADD 1 TO g_row.
g_col = 1.
PERFORM fill_cell USING g_row g_col 'Total' 'X' '' '' '' ''.
PERFORM fill_cell USING g_row g_col '=SUM(B13:B14)' 'X' 'X' '' '' ''.
PERFORM fill_cell USING g_row g_col '0.00' 'X' 'X' '' '' ''.
PERFORM copy_cell USING g_row 2 17 5 25 8.
ENDFORm. " ADD_WORKSHEET2
*& Form MERGE_CELL
FORM merge_cell USING i_row1 i_col1
i_row2 i_col2.
CALL METHOD OF g_excel 'Cells' = g_cell1
EXPORTING #1 = i_row1
#2 = i_col1.
CALL METHOD OF g_excel 'Cells' = g_cell2
EXPORTING #1 = i_row2
#2 = i_col2.
CALL METHOD OF g_excel 'Range' = g_cellrange
EXPORTING #1 = g_cell1
#2 = g_cell2.
CALL METHOD OF g_cellrange 'Merge'.
ENDFORM. " MERGE_CELL
*& Form SET_BORDER
FORM set_border USING i_row1 i_col1
i_row2 i_col2
i_thickness
i_allborders.
CALL METHOD OF g_excel 'Cells' = g_cell1
EXPORTING #1 = i_row1
#2 = i_col1.
CALL METHOD OF g_excel 'Cells' = g_cell2
EXPORTING #1 = i_row2
#2 = i_col2.
CALL METHOD OF g_excel 'Range' = g_cellrange
EXPORTING #1 = g_cell1
#2 = g_cell2.
IF i_allborders IS INITIAL.
CALL METHOD OF g_cellrange 'BorderAround'
EXPORTING #1 = 1 "Continuous line
#2 = i_thickness. "Thickness: 1 - Normal, 4 - Thick
ELSE.
GET PROPERTY OF g_cellrange 'Borders' = g_borders.
SET PROPERTY OF g_borders 'LineStyle' = '1'.
SET PROPERTY OF g_borders 'Weight' = i_thickness.
ENDIF.
ENDFORM. " SET_BORDER
*& Form SET_COLOR
FORM set_color USING i_row1 i_col1
i_row2 i_col2
i_color.
DATA: l_colorindex TYPE i.
CASE i_color.
WHEN 'BK'.
l_colorindex = 1. "Black
WHEN 'BR'.
l_colorindex = 53. "Brown
WHEN 'OG'.
l_colorindex = 52. "Olive Green
WHEN 'DG'.
l_colorindex = 51. "Dark Green
WHEN 'DT'.
l_colorindex = 49. "Dark Teal
WHEN 'DB'.
l_colorindex = 11. "Dark Blue
WHEN 'ID'.
l_colorindex = 55. "Indigo
WHEN 'G4'.
l_colorindex = 56. "Gray 80%
WHEN 'DR'.
l_colorindex = 9. "Dark Red
WHEN 'OR'.
l_colorindex = 46. "Orange
WHEN 'DY'.
l_colorindex = 12. "Dark Yellow
WHEN 'GR'.
l_colorindex = 10. "Green
WHEN 'TL'.
l_colorindex = 14. "Teal
WHEN 'BL'.
l_colorindex = 5. "Blue
WHEN 'BY'.
l_colorindex = 47. "Blue Gray
WHEN 'G3'.
l_colorindex = 16. "Gray 50%
WHEN 'RD'.
l_colorindex = 3. "Red
WHEN 'LO'.
l_colorindex = 45. "Light Orange
WHEN 'LI'.
l_colorindex = 43. "Lime
WHEN 'SG'.
l_colorindex = 50. "Sea Green
WHEN 'AQ'.
l_colorindex = 42. "Aqua
WHEN 'LB'.
l_colorindex = 41. "Light Blue
WHEN 'VL'.
l_colorindex = 13. "Violet
WHEN 'G2'.
l_colorindex = 48. "Gray 40%
WHEN 'PK'.
l_colorindex = 7. "Pink
WHEN 'GD'.
l_colorindex = 44. "Gold
WHEN 'YL'.
l_colorindex = 6. "Yellow
WHEN 'BG'.
l_colorindex = 4. "Bright Green
WHEN 'TQ'.
l_colorindex = 8. "Turquoise
WHEN 'SB'.
l_colorindex = 33. "Sky Blue
WHEN 'PL'.
l_colorindex = 54. "Plum
WHEN 'G1'.
l_colorindex = 15. "Gray 25%
WHEN 'RS'.
l_colorindex = 38. "Rose
WHEN 'TN'.
l_colorindex = 40. "Tan
WHEN 'LY'.
l_colorindex = 36. "Light Yellow
WHEN 'LG'.
l_colorindex = 35. "Light Green
WHEN 'LT'.
l_colorindex = 34. "Light Turquoise
WHEN 'PB'.
l_colorindex = 37. "Pale Blue
WHEN 'LV'.
l_colorindex = 39. "Lavender
WHEN 'WH'.
l_colorindex = 2. "White
WHEN OTHERS.
l_colorindex = 2. "White
ENDCASE.
CALL METHOD OF g_excel 'Cells' = g_cell1
EXPORTING #1 = i_row1
#2 = i_col1.
CALL METHOD OF g_excel 'Cells' = g_cell2
EXPORTING #1 = i_row2
#2 = i_col2.
CALL METHOD OF g_excel 'Range' = g_cellrange
EXPORTING #1 = g_cell1
#2 = g_cell2.
GET PROPERTY OF g_cellrange 'Interior' = g_interior.
SET PROPERTY OF g_interior 'ColorIndex' = l_colorindex.
ENDFORM. " SET_COLOR
*& Form COPY_CELL
FORM copy_cell USING i_crow i_ccol
i_prow1 i_pcol1
i_prow2 i_pcol2.
CALL METHOD OF g_excel 'Cells' = g_cell
EXPORTING #1 = i_crow
#2 = i_ccol.
CALL METHOD OF g_cell 'Copy'.
CALL METHOD OF g_excel 'Cells' = g_cell1
EXPORTING #1 = i_prow1
#2 = i_pcol1.
CALL METHOD OF g_excel 'Cells' = g_cell2
EXPORTING #1 = i_prow2
#2 = i_pcol2.
CALL METHOD OF g_excel 'Range' = g_cellrange
EXPORTING #1 = g_cell1
#2 = g_cell2.
CALL METHOD OF g_worksheet 'Paste'
EXPORTING #1 = g_cellrange.
ENDFORM. " COPY_CELL
*& Form OPEN_TEMPLATE_FILE
FORM open_template_file.
CALL METHOD OF g_workbooks 'Open' = g_tmp_workbook
EXPORTING #1 = g_pc_template
#2 = 2
#3 = 0
#4 = 1
#5 = 0
#6 = 0
#7 = 1.
CALL FUNCTION 'FLUSH'
EXCEPTIONS
OTHERS = 0.
GET PROPERTY OF g_tmp_workbook 'Worksheets' = g_tmp_worksheets.
GET PROPERTY OF g_tmp_worksheets 'Item' = g_tmp_worksheet1
exporting #1 = 1.
GET PROPERTY OF g_tmp_worksheets 'Item' = g_tmp_worksheet2
exporting #1 = 2.
CALL METHOD OF g_tmp_worksheet1 'Copy'
EXPORTING #1 = g_worksheet.
CALL METHOD OF g_tmp_worksheet2 'Copy'
EXPORTING #1 = g_worksheet.
call method of g_tmp_workbook 'Close'.
CALL FUNCTION 'FLUSH'
EXCEPTIONS
OTHERS = 0.
ENDFORM. " OPEN_TEMPLATE_FILE -
Creation of function module for updating the ztable
Hi,
I am sending the requirement for ceation of function module for updating the ztable.
Requirement----
Table Updation rule (New record)
While creating a new record the calling function will export the following to the table handling function.
Table field Probable Values
ZORDERNO-------> Sales Delivery no in case of sales orderShipment no in case of transfer order
UNAME----
> User ID
ZORDTYPE----
> SALEOR in case of sales orderTRANSF in case of transfer order
ZREFDOCNO----
>Sales Order no in case of sales orderPurchase Order no in case of transfer order
ZREFDOCNO1----
>Delivery no in case of transfer order
The table handling function will calculate the following fields
Table field Probable Values
ZREQNO----
>Running serial number (incremented by 1 for each new record)
ZREQDAT -
>System date
ZREQTIME----
> System time
ZSTATUS----
>OPEN (for all new records)
Before inserting a new record the table handling function will always check if a previous record exists for the same order / shipment no. if record exists the function will not insert a new record.
Table Updation rule (Status Update)
While updating a record the calling function will export the following to the table handling function.
Table field Probable Values
ZORDERNO----
>Sales order no in case of sales orderShipment no in case of transfer order
ZSTATUS----
>CANCEL if cancellation successfulERROR if cancellation not possible (order already processed)
The table handling function will calculate the following fields
Table field Probable Values
ZSTATDAT----
>System date
ZSTATTIME----
> System timeDo you have to create/update new record in Ztable through Function Module ?
or you need to write FM only for validation?
Any how, you need to create a Program with Input values for the fields of Ztable, and for rest of fields the Value can be calculated based on input as per your requirement.
Let me know clearly what exactly u need ?
Regards,
Kiran -
Why Service Call and why not call Function module Directly in WD ABAP
Hi,
I have created a Webdynpro applications and the logic requires calling avrious Function modules.
Do I need to create Service Call for each Function module or call them directly.
It would be great if you can suggest me under what cases I need to opt for Service call
For example, if I use 'RP_CALC_DATE_IN_INTERVAL', do I need to use Service call or call function module directly.
Note: I have searched forums but could not get the correct answer which I want
Thanks!The Service Call is really meant to be a wizard/time saver. It has the advantage that it can generate matching context nodes/attributes for the interface of the Function Module you are calling. However everything that the service call does can also be created by hand.
Personally I'm not a fan of what the service call wizard generates. Its good as a time saver or for beginners, but I find I prefer to touch up the code it generates anyway. I much prefer to create a nice reusable model class with its own unit test and then consume this model class (with the service call wizard) from WD. This model class might contain one or more function module calls depending upon what logic I need to access. -
Function module for Fiscal period ( monat field name)
Hi ,
please suggest the function module for (monat) Fiscal period. our reqirement is default to previous accounting period from the current month.
Thnks
SrinivasHi,
Refer to the following code:
DATA: LV_FISCAL_YEAR_VAR(2) TYPE C,
LV_PERIOD LIKE T009B-POPER.
CALL FUNCTION 'CCODE_GET_FISCAL_YEAR_VARIANT'
EXPORTING
COMPANY_CODE = S_BUKRS-LOW
IMPORTING
FISCAL_YEAR_VARIANT = LV_FISCAL_YEAR_VAR
EXCEPTIONS
COMPANY_CODE_NOT_FOUND = 1
OTHERS = 2.
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
I_DATE = P_BUDAT
* I_MONMIT = 00
I_PERIV = LV_FISCAL_YEAR_VAR
IMPORTING
E_BUPER = LV_PERIOD
* E_GJAHR =
EXCEPTIONS
INPUT_FALSE = 1
T009_NOTFOUND = 2
T009B_NOTFOUND = 3
OTHERS = 4 -
Calling Function Module in Update Task
Hello Experts,
Can anyone let me know about
Calling Function Module in Update Task.
Why do we use this " In Update Task " ??
How do we Use ??
What is the Use... ??
Kindly let me know....
Thanks and Regards
Pramodhi,
Why do we use this " In Update Task " ??
The main update technique for bundling database changes in a single database LUW is to use CALL FUNCTION... IN UPDATE TASK.
How do we Use ??
A typical R/3 installation contains dialog work processes and at least one update work process. The update work processes are responsible for updating the database. When an ABAP program reaches a COMMIT WORK statement, any function modules from CALL FUNCTION... IN UPDATE TASK statements are released for processing in an update work process. The dialog process does not wait for the update to finish. This kind of update is called asynchronous update.
What is the Use... ??
Asynchronous update is useful when response time from the transaction is critical, and the database updates themselves are so complex that they justify the extra system load
Real time scenario.
Suppose a user wants to change an entry in a database table, or add a new one. He or she enters the necessary data, and then starts the update process by choosing Save. This starts the following procedure in the ABAP program:
Firstly, the program locks the database entry against other users, using the enqueue work process (or the message server in the case of a distributed system). This generates an entry in the lock table. The user is informed whether the update was successful, or whether the lock could not be set because of other users.
If the lock is set, the program reads the entry that is to be changed and modifies it. If the user has created a new entry, the program checks whether a record with the same key values already exists.
In the current dialog work process, the program calls a function module using CALL FUNCTION... IN UPDATE TASK, and this writes the change details as an entry in table VBLOG.
When the program is finished (maybe after further dialog steps), a COMMIT WORK statement starts the final part of the SAP LUW. The work process that is processing the current dialog step starts an update work process.
Based on the information passed to it from the dialog work process, the update work process reads the log entries belonging to the SAP LUW from table VBLOG.
The update work process passes this data to the database for updating, and analyzes the return message from the database. If the update was successful, the update work process triggers a database commit after the last database change and deletes the log entries from table VBLOG.
If an error occurred, the update work process triggers a database rollback, leaves the log entries in table VBLOG, flags them as containing errors, and sends a SAPoffice message to the user, who should then inform the system administrator.
The corresponding entries in the lock table are reset by the update work process.
Hope this is helpful, Do reward. -
Any function module for validation
Hi,
I am new to ABAP.
Can any body tell me whether there is any built in function module for
field validation.
Thanks in advance
ArchanaHi,
u can validate the field values using at selectiion-screen
AT SELECTION-SCREEN
When user enters the values in the fields of selection screen and clicks on execute button, this event gets triggered. This event is basically for checking the values entered by the user for the fields of the selection screen i.e., data validity checking. This event is for entire selection screen. For example:
You are accepting carrid, connid, fldate from user and you dont want to proceed if user enters no value for carrid and fldate. Using AT SELECTION-SCREEN can do this.
Select-options: carrid1 for sflight-carrid,
Connid1 for sflight-connid,
F1date1 for sflight-f1date.
AT SELECTION-SCREEN.
If carrid1-low ne and fldate1-low = .
Error message.
Endif.
In this case, if both the fields are entered blank, then the user gets error message.
Basically, this event is for many fields on selection screen. Usually, it is for the fields which are logically related.
AT SELECTION-SCREEN ON <field>
When you want to check for specific value of a field. For example, carrid should be in the range of LH and SQ. This can be done in this event. Basically, this event is for checking individual fields. You can have many AT selection-screen events in your program (i.e., for each field specified in the Select-Options).
Select-Options carrid1 for sflight-carrid.
AT SELECTION-SCREEN.
If carrid1-low ne LH and carrid1-high ne SQ.
Error message.
Endif.
Here the system will not proceed on entering wrong values.
Regards,
Sruthi -
Generic function module for delta - which FM ?
Hi all,
I want to create a custom generic datasource in R3 which uses a function module for delta extraction. This is straight forward for full extract (copy FM RSAX_BIW_GET_DATA_SIMPLE - I already did this and have a full extraction working to BW). However I need to extract delta - and the above function module does not have example code for that (I have seen some forum posts that it 'can' be used - but this looks like a pseudo get around where the delta field name is passed in I_T_SELECT).
FM RSVD_BW_GET_DELTA_DATA seems to be an example code of a FM which can allow delta (i.e. manually codes how to fill date/time stamp information). However when I code this and try test in RSA3 it seems to try to populate the delta selection field before calling my function module! I need it to call my function and allow the function to specifiy the date criteria.
Can anyone help with an example of how this should best be done ?
Or can it only be done in a pseudo form using 'RSAX_BIW_GET_DATA_SIMPLE' example FM.
Note: I have setup the RSO2 datasource to allow delta.
Also - I have spent several hours searching the forum - but please answer with a link if you think it does answer exactly this problem.
Thanks for any help
MartinHi again,
Have had a few requests for the code I used - I created a new custom function copied from 'RSAX_BIW_GET_DATA_SIMPLE'. AEDAT has been set as the delta date for this data source in transaction RSO2.
Main sample code is -
1. Code to receive selection criteria and store in internal ranges -
FUNCTION zbw_sodetail_get_detail.
""Global interface:
*" IMPORTING
*" VALUE(I_REQUNR) TYPE SRSC_S_IF_SIMPLE-REQUNR
*" VALUE(I_DSOURCE) TYPE SRSC_S_IF_SIMPLE-DSOURCE
*" VALUE(I_MAXSIZE) TYPE SRSC_S_IF_SIMPLE-MAXSIZE
*" VALUE(I_INITFLAG) TYPE SRSC_S_IF_SIMPLE-INITFLAG
*" VALUE(I_READ_ONLY) TYPE SRSC_S_IF_SIMPLE-READONLY
*" TABLES
*" I_T_SELECT TYPE SRSC_S_IF_SIMPLE-T_SELECT OPTIONAL
*" I_T_FIELDS TYPE SRSC_S_IF_SIMPLE-T_FIELDS OPTIONAL
*" E_T_DATA STRUCTURE ZBW_SODETAIL OPTIONAL
*--- Sales order item create date
LOOP AT i_t_select INTO l_s_select WHERE fieldnm = 'ERDAT'.
MOVE-CORRESPONDING l_s_select TO r_erdat.
APPEND r_erdat.
ENDLOOP.
*--- Sales order item change date - DELTA only - auto filled before
this function is called.
C (Initialise Delta) - Low = blank, High = today - safety limit
D (Delta) - low = , High = . *from roosgendlm
LOOP AT i_t_select INTO l_s_select WHERE fieldnm = 'AEDAT'.
MOVE-CORRESPONDING l_s_select TO r_aedat.
APPEND r_aedat.
ENDLOOP.
2. Code to use selection criteria to get initial or delta. Note that for delta the delta date field to be used is automatically populated with the date of the last delta run (from table roosgendlm) -
SELECT VBAK~KNUMV
VBAPVBELN VBAPPOSNR VBAPMATNR VBAPARKTX VBAP~SPART
VBAPWERKS VBAPERDAT VBAPAEDAT VBAPNETWR VBAP~WAERK
VBAPABGRU VBAPZPROMISE VBAP~CUOBJ
VBEP~EDATU
INTO CORRESPONDING FIELDS OF TABLE ZBW_SODETAIL_ITAB
FROM VBAK JOIN VBAP ON VBAKVBELN = VBAPVBELN
JOIN VBEP ON VBAPVBELN = VBEPVBELN
AND VBAPPOSNR = VBEPPOSNR
WHERE VBAP~VBELN IN R_VBELN "Order number
AND VBAP~POSNR IN R_POSNR "Order item number
AND VBAP~ERDAT IN R_ERDAT "Order item date created
AND ( VBAP~ERDAT IN R_AEDAT OR "Created date in Delta range
VBAP~AEDAT IN R_AEDAT OR "Order item change Delta range
VBAK~AEDAT IN R_AEDAT ). "Order header change Delta range
Note that if the data source is called in initial or full extract mode the delta change date (aedat) will automatically be blank.
I have been using this successfully.
I hope this helps
Martin. -
Help in calling function module
need to call a function module, for security purpose, do not want to show the name of function module,
how it can be done ?
Study SAPI think the responders so far don't understand the question. But that's probably because you don't state it very well. What you want is a way to call a function module without having the name of the function module in the program. Easy.
Create a table with one field, perhaps in an encrypted format. Let's say you've a function module (DECRYPT) that decrypts the entry in the table to plain text.
SELECT SINGLE field FROM my_table INTO my_field.
CALL FUNCTION 'DECRYPT' exporting output = my_field
importing input = plain_text.
CALL FUNCTION plain_text.
You should have noticed that in most cases, where you see CALL FUNCTION, it is followed by a character literal. CALL FUNCTION 'SOME_FUNCTION'. You see, it's encased in quote. That makes it a literal. You can replace the name of the function module, with the quotes, with any character like variable that contains the function name.
matt -
Regarding Function Module for Locking ( enque)
Hi,
I am facing a Problem that is when iam running Call transaction one popup is coming because some other user currently editing that Tcode at that time i need to lock tcode using enque specially for table . If suppose some other user editing at that time it will shoe that popup and it will exit from their with out doing any other process For that i need Function module for Lock and Delock.
thanks in advance,
murali krishna.So in this example, I am doing a loop and check for a lock, if I don't get one, I wait for 5 seconds, this loop continues untill 30 seconds, no lock then it quits and gives message.
report zrich_0001.
data: counter type i.
parameters: p_equnr type equi-equnr.
start-of-selection.
clear counter.
do.
Exhausted, no luch in getting a lock, get of of DO loop.
if counter > 6.
sy-subrc = 1.
exit.
endif.
Try for lock
call function 'ENQUEUE_EIEQUI'
exporting
mode_equi = 'E'
mandt = sy-mandt
equnr = p_equnr
_wait = 'X'
exceptions
foreign_lock = 1
system_failure = 2
others = 3.
Got a lock, get out of DO loop.
if sy-subrc = 0.
exit.
endif.
Still here? Then wait another 5 seconds
wait up to 5 seconds.
counter = counter + 1.
enddo.
Report status
case sy-subrc.
when 0.
message s001(00) with 'Lock could not be established'.
when 1.
message i001(00) with 'Lock could not be established'.
endcase.
Regards,
rewards point
Maybe you are looking for
-
How do i configure the usb port on a draytek vigor 2820n router for use with my imac
i have an imac connected to the internet through a draytek vigor 2820n router. this router has a USB port with a HP Deskjet 5560 printer attached (for use as a network printer for other machines on the network). How do I configure this printer on the
-
Calling procedure in oracle forms
Hi all,i have a procedure in the backend and when i am calling it in forms nothing happens.The procedure is syntactically correct. Procedure PROCEDURE XXC_MTL_TRANSACTIONS(v_file_number IN VARCHAR2) IS BEGIN INSERT INTO mtl_transactions_interface
-
Blackberry Password works for phone but not for Desktop Manager
Hi guys, I´m a first time user of BB and very pleased with the purchase. I recently setup a password to protect my phone. When it locks I simply type the password and it unlocks. To my surprise when I tryed to sync with the Desktop Manager it asks fo
-
Manually process GR slip print WE01
Hi I have manually added an output type WE01 in MB02. I can see the same in NAST table Please suggest me which T-code/table to use for processing the message. I tried MB90. But it couldnot find any record to process regards Shetty
-
HI, can you provide me with some details "how to start" with webdynpro creation ? I´m new to this. Some Blogs or Hints would be helpful