Writing Function Modules
Hi
I want to learn how to write function modules in ABAP please guide me how should I proceed to learn it as fast as I can.
Are there any Demos or PDF documents for that.
I have gone through ABAPDocu but it has a lot of unwanted materials as well and I found it a bit unstructured to learn writing function modules.
Hi,
Please chek this link
Function Groups
http://help.sap.com/saphelp_nw70/helpdata/en/9f/db992335c111d1829f0000e829fbfe/content.htm
Creating Function Modules
http://help.sap.com/saphelp_nw70/helpdata/en/9f/db98fc35c111d1829f0000e829fbfe/content.htm
Best regards,
Brijesh
Similar Messages
-
Guys, Can someone tell me the difference between writing function modules and writing routines and when to use each? I know how to get to routines screen to write those routines but I have no clue about function modules. If someone can tell me how to write them or direct me to a document that explains the process will be much appreciated.
Thanks,
RGhi,
chk out the links
Enhancements in SAP BW
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/59069d90-0201-0010-fd81-d5e11994d8b5
Customer Enhancements in SAP NetWeaver BI (Exits, BAdIs and ABAP in the SAP NetWeaver BI Back End)
http://www.sap.com/community/pub/showdetail.epx?itemID=5257
Ramesh -
Writing to FI-GL records to Delta Queue using a Function Module
Has anyone of you tried to write FI-GL transactions to delta queue using BTE by configuring a function module. I am trying to achieve it for a datasource based on a view on FAGLFLEXA table (GL Line Items). For some reason I am not able to see records in Delta Queue. I am doing this to achieve RDA functionality. If you have done it please sends me step sequence and the name of FM.
Your help would be highly appreciable.
Regards,
RamHello Ram,
See this SAP Network Blog: [Generic Extraction via Function Module|/people/siegfried.szameitat/blog/2005/09/29/generic-extraction-via-function-module]
Have a look at these docs,
[How to Create Generic Data Sources which use the Delta Queue (NW7.0)|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/10b68b99-022e-2a10-999d-c4dc9ec24a59]
[How to Create Generic DataSources Which Use the Delta Queue (NW2004)|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/d3219af2-0c01-0010-71ac-dbb4356cf4bf]
[How to Create Generic Delta|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/84bf4d68-0601-0010-13b5-b062adbb3e33]
Thanks
Chandran -
Urgent: Problems in Generic Extraction by Function Module
Hi BW Gurus,
I am new to SDN and also new to generic extraction using function module. My requirement is to extract long text(142 char) from CRM to BW as the text is not stored in database table I used function module read_text with in another ZXXX function module copy of (RSAX_BIW_GET_DATA_SIMPLE). In my extract structure I used GUID(char,32), Langu, long text(142 char) and 2 placeholders. Text can be extracted by passing STXH table fields(Tdname, Tdid, Tdobject, Tdspars) to read_text as parameters and i also need to use CRMD_ORDERADM_H field GUID(32 char) to compare 1st 32 chars of tdname(70 char) with Guid to select Guids and loop thru this Guids and for each Guid i need to append lines of text to e_t_data but as i donot know ABAP i unable to write the code for this. Through my friends help i wrote code when i check in RSA3 it is displaying the text but when i replicate into BW and load into data target in monitor the status is red with records initially but afterwards it will be red status again with 0 from 0 records for initial load again.when i check on job logs the errors i have are:
The background job has created a job log file of 2Gb size and it is currently on a infinite loop writing entries into the SAP System Log that it cannot write to the Job log file due to Error 22 for write/read access to a file this is because of the datasource i have created. Please find my Function module and if anyone would please correct FM and send me that will be really great.I appreciate it in advance.
MY Function Module is:
FUNCTION Z_CRMORDERH_STR_TXT.
""Local Interface:
*" IMPORTING
*" VALUE(I_REQUNR) TYPE SRSC_S_IF_SIMPLE-REQUNR
*" VALUE(I_DSOURCE) TYPE SRSC_S_IF_SIMPLE-DSOURCE OPTIONAL
*" VALUE(I_MAXSIZE) TYPE SRSC_S_IF_SIMPLE-MAXSIZE OPTIONAL
*" VALUE(I_INITFLAG) TYPE SRSC_S_IF_SIMPLE-INITFLAG OPTIONAL
*" VALUE(I_READ_ONLY) TYPE SRSC_S_IF_SIMPLE-READONLY OPTIONAL
*" VALUE(I_REMOTE_CALL) TYPE SBIWA_FLAG DEFAULT SBIWA_C_FLAG_OFF
*" 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 YCRM_TEXT_STR OPTIONAL
*" EXCEPTIONS
*" NO_MORE_DATA
*" ERROR_PASSED_TO_MESS_HANDLER
***" EXCEPTIONS NO_MORE_DATA
*" ERROR_PASSED_TO_MESS_HANDLER
Tables: CRMD_ORDERADM_H, STXH.
Auxiliary Selection criteria structure
data: l_s_select type srsc_s_select.
Maximum number of lines for DB table
Statics: s_s_if type srsc_s_if_simple,
counter
s_counter_datapakid like sy-tabix,
Cursor
s_cursor type cursor.
data: i_crmtext type standard table of TLINE .
types: begin of xsreph ,
GUID type CRMD_ORDERADM_H-guid,
end of xsreph.
data: i_guid type standard table of xsreph.
data: I_TEXT type STXH-TDNAME.
data: xempl like YCRM_TEXT_STR occurs 0 with header line.
data: t_tab like dd03l-tabname.
Select ranges
ranges: l_r_guid for CRMD_ORDERADM_H-guid.
l_r_connid for sflight-connid.
Initialization mode (first call by SAPI) or data transfer mode
(following calls) ?
if i_initflag = sbiwa_c_flag_on.
Initialization: check input parameters
buffer input parameters
prepare data selection
Check DataSource validity
case i_dsource.
when 'yCRM_TEXT'. " for S_SREPH1
when others.
if 1 = 2. message e009(r3). endif.
this is a typical log call. Please write every error message like this
log_write 'E' "message type
'R3' "message class
'009' "message number
i_dsource "message variable 1
' '. "message variable 2
raise error_passed_to_mess_handler.
endcase.
append lines of i_t_select to s_s_if-t_select.
Fill parameter buffer for data extraction calls
s_s_if-requnr = i_requnr.
s_s_if-dsource = i_dsource.
s_s_if-maxsize = i_maxsize.
Fill field list table for an optimized select statement
(in case that there is no 1:1 relation between InfoSource fields
and database table fields this may be far from beeing trivial)
append lines of i_t_fields to s_s_if-t_fields.
we will do our selection based on what is in the p table for the
infoobject
else. "Initialization mode or data extraction ?
Data transfer: First Call OPEN CURSOR + FETCH
Following Calls FETCH only
First data package -> OPEN CURSOR
if s_counter_datapakid = 0.
Fill range tables BW will only pass down simple selection criteria
of the type SIGN = 'I' and OPTION = 'EQ' or OPTION = 'BT'.
LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'GUID'.
MOVE-CORRESPONDING L_S_SELECT TO L_R_GUID.
APPEND L_R_GUID.
ENDLOOP.
case i_dsource.
when 'YCRM_TEXT'. " for S_SREPH1
t_tab = 'CRMD_ORDERADM_H'.
endcase.
select GUID
from (t_tab)
into table i_guid where PROCESS_TYPE = 'ZACI' and ( OBJECT_ID < '0000000042').
select tdname from stxh into i_text where tdobject = 'TEXT'.
if sy-subrc ne 0.
message e009(r3).
this is a typical log call. Please write every error message like this
log_write 'E' "message type
'R3' "message class
'009' "message number
i_dsource "message variable 1
'No master data found'. "message variable 2
raise error_passed_to_mess_handler.
endif.
Determine number of database records to be read per FETCH statement
from input parameter I_MAXSIZE. If there is a one to one relation
between DataSource table lines and database entries, this is trivial.
In other cases, it may be impossible and some estimated value has to
be determined.
open cursor with hold s_cursor for
select (s_s_if-t_fields) from CRMD_ORDERADM_H
where GUID in L_R_GUID .
ENDIF.
Fetch records into interface table.
named E_T_'Name of extract structure'.
fetch next cursor s_cursor
appending corresponding fields
of table e_t_data
package size s_s_if-maxsize.
IF SY-SUBRC <> 0.
CLOSE CURSOR S_CURSOR.
RAISE NO_MORE_DATA.
ENDIF.
as we are doing this only once can use the select statement.
***data: crmtext like tline occurs 0 with header line.
**data: i_crmtext type standard table of TLINE.
**data: i_guid type standard table of xsreph.
data: l_guid type THEAD-TDNAME.
data: st_guid type xsreph.
data: st_crmtext type TLINE.
data: lan type THEAD-TDSPRAS.
lan = 'E'.
loop at i_guid into st_guid.
l_guid = st_guid-guid.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = 'A002'
LANGUAGE = lan
NAME = l_guid
OBJECT = 'CRM_ORDERH'
ARCHIVE_HANDLE = 0
LOCAL_CAT = ' '
IMPORTING
HEADER =
TABLES
LINES = i_crmtext.
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8
e_t_data-guid = l_guid.
loop at i_crmtext into st_crmtext.
move lan to e_t_data-langu.
move st_crmtext-tdline to e_t_data-description.
append e_t_data.
endif.
endloop.
clear: st_guid,l_guid.
refresh: i_crmtext.
endloop.
S_COUNTER_DATAPAKID = S_COUNTER_DATAPAKID + 1.
endif.
ENDFUNCTION.
please Gurus as I donot know ABAP i appreciate if anyone would write a FM based on requirement and send me that will be really great this is my request. I gurantee of award points for good answers.
Regards
KishoreHi,
The statement <b>RAISE NO_MORE_DATA</b> should be active (uncommented) in your code. Otherwise, the infinte loop occurs.
See also, the Siggi's blog:
/people/siegfried.szameitat/blog/2005/09/29/generic-extraction-via-function-module
BTW, was it your thread here:
Re: Urgent: problems in extracting Long Text
Best regards,
Eugene -
Generic datasource by function module to fetch data from multiple tables?
I'm writing a function module to fetch price, for generic datasource.
At first, extract test is OK. But InfoPackage never stop when loading data to PSA in BW.
And I find the example codes:
OPEN CURSOR WITH HOLD S_CURSOR FOR
SELECT (S_S_IF-T_FIELDS) FROM SFLIGHT
WHERE CARRID IN L_R_CARRID AND
CONNID IN L_R_CONNID.
ENDIF. "First data package ?
* Fetch records into interface table.
* named E_T_'Name of extract structure'.
FETCH NEXT CURSOR S_CURSOR
APPENDING CORRESPONDING FIELDS
OF TABLE E_T_DATA
PACKAGE SIZE S_S_IF-MAXSIZE.
IF SY-SUBRC <> 0.
CLOSE CURSOR S_CURSOR.
RAISE NO_MORE_DATA.
ENDIF.
S_COUNTER_DATAPAKID = S_COUNTER_DATAPAKID + 1.
ENDIF.
There using Cursor to fetch data package by package, and raise exception NO_MORE_DATA to stop the loading process.
Now I fetch data from multiple tables, I don't think I can use Cursor.
Then How can I handle this?
Thanks a lot.Thanks
IF IT_999[] IS INITIAL.
SELECT A~KNUMH A~MATNR A~KSCHL VKORG VTWEG A~DATBI A~DATAB KBETR KMEIN KPEIN C~MTART APPENDING CORRESPONDING FIELDS OF
TABLE TP_DATA
FROM A999 AS A
INNER JOIN KONP AS B
ON A~KNUMH = B~KNUMH
INNER JOIN MARA AS C
ON A~MATNR = C~MATNR
* FOR ALL ENTRIES IN IT_999
WHERE
* A~KNUMH = IT_999-KNUMH AND
( ( A~KSCHL = 'ZPRC' AND VKORG = 'Z000' AND VTWEG = 'Z1' ) OR
( A~KSCHL = 'ZPRD' AND VKORG = 'A000' AND VTWEG = 'Y3' ) ) AND
* A~DATBI >= SY-DATUM AND
LOEVM_KO = ''.
SELECT A~KNUMH A~MATNR A~KSCHL VKORG VTWEG A~DATBI A~DATAB KBETR AS KHETR KMEIN KPEIN C~MTART APPENDING CORRESPONDING FIELDS OF
TABLE TP_DATA
FROM A999 AS A
INNER JOIN KONP AS B
ON A~KNUMH = B~KNUMH
INNER JOIN MARA AS C
ON A~MATNR = C~MATNR
* FOR ALL ENTRIES IN IT_999
WHERE
* A~KNUMH = IT_999-KNUMH AND
A~KSCHL = 'ZPR3' AND A~VKORG = 'I000' AND
* DATBI >= SY-DATUM AND
LOEVM_KO = ''.
ENDIF.
IF IT_997[] IS INITIAL.
SELECT A~KNUMH A~MATNR A~KSCHL VTWEG A~DATBI A~DATAB KBETR AS KHETR KMEIN KPEIN C~MTART APPENDING CORRESPONDING FIELDS OF
TABLE TP_DATA
FROM A997 AS A
INNER JOIN KONP AS B
ON A~KNUMH = B~KNUMH
INNER JOIN MARA AS C
ON A~MATNR = C~MATNR
* FOR ALL ENTRIES IN IT_997
WHERE
* A~KNUMH = IT_997-KNUMH AND
A~KSCHL = 'ZPRA' AND VTWEG = 'Y1' AND
* DATBI >= SY-DATUM AND
LOEVM_KO = ''.
ENDIF.
IF IT_996[] IS INITIAL.
SELECT A~KNUMH A~MATNR A~KSCHL A~DATBI A~DATAB KBETR AS KHETR KMEIN KPEIN C~MTART APPENDING CORRESPONDING FIELDS OF
TABLE TP_DATA
FROM A996 AS A
INNER JOIN KONP AS B
ON A~KNUMH = B~KNUMH
INNER JOIN MARA AS C
ON A~MATNR = C~MATNR
* FOR ALL ENTRIES IN IT_996
WHERE
* A~KNUMH = IT_996-KNUMH AND
A~KSCHL = 'ZPRB' AND
* DATBI >= SY-DATUM AND
LOEVM_KO = ''.
ENDIF.
SELECT MATNR "u7269u6599u53F7u7801
MEINH "u4ED3u50A8u5355u4F4Du7684u5907u7528u8BA1u91CFu5355u4F4D
UMREZ "u57FAu672Cu8BA1u91CFu5355u4F4Du8F6Cu6362u5206u5B50
UMREN "u8F6Cu6362u4E3Au57FAu672Cu8BA1u91CFu5355u4F4Du7684u5206u6BCD
FROM MARM
INTO CORRESPONDING FIELDS OF TABLE IT_MARM
FOR ALL ENTRIES IN TP_DATA
WHERE MATNR = TP_DATA-MATNR AND MEINH = TP_DATA-KMEIN.
LOOP AT TP_DATA.
IF TP_DATA-KPEIN NE 0.
TP_DATA-KBETR = TP_DATA-KBETR / TP_DATA-KPEIN.
TP_DATA-KHETR = TP_DATA-KHETR / TP_DATA-KPEIN.
ENDIF.
IF TP_DATA-KSCHL = 'ZPRA'.
* TP_DATA-MEINH = 'ZI'.
* TP_DATA-KSCHL = 'B4'.
IF TP_DATA-KMEIN = 'ZI'.
TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
ELSE.
READ TABLE IT_MARM INTO WA_MARM1 WITH KEY MATNR = TP_DATA-MATNR MEINH = TP_DATA-KMEIN.
* READ TABLE IT_MARM INTO WA_MARM2 WITH KEY MATNR = TP_DATA-MATNR MEINH = 'CT'.
TP_DATA-KHETR = TP_DATA-KHETR * WA_MARM1-UMREN / WA_MARM1-UMREZ.
* * WA_MARM2-UMREZ / WA_MARM2-UMREN.
TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
ENDIF.
ELSEIF TP_DATA-KSCHL = 'ZPRB'.
* TP_DATA-KSCHL = 'L0'.
* TP_DATA-MEINH = 'ZI'.
IF TP_DATA-KMEIN = 'ZI'.
TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
ELSE.
READ TABLE IT_MARM INTO WA_MARM1 WITH KEY MATNR = TP_DATA-MATNR MEINH = TP_DATA-KMEIN.
* READ TABLE IT_MARM INTO WA_MARM2 WITH KEY MATNR = TP_DATA-MATNR MEINH = 'BAG'.
TP_DATA-KHETR = TP_DATA-KHETR * WA_MARM1-UMREN / WA_MARM1-UMREZ.
* * WA_MARM2-UMREZ / WA_MARM2-UMREN.
TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
ENDIF.
ELSEIF TP_DATA-KSCHL = 'ZPRC' OR TP_DATA-KSCHL = 'ZPRD'.
* TP_DATA-MEINH = 'ZI'.
IF TP_DATA-KMEIN = 'ZI'.
TP_DATA-KHETR = TP_DATA-KBETR * '1.17'.
ELSE.
READ TABLE IT_MARM INTO WA_MARM1 WITH KEY MATNR = TP_DATA-MATNR MEINH = TP_DATA-KMEIN.
* READ TABLE IT_MARM INTO WA_MARM2 WITH KEY MATNR = TP_DATA-MATNR MEINH = 'WZI'.
TP_DATA-KBETR = TP_DATA-KBETR * WA_MARM1-UMREN / WA_MARM1-UMREZ.
* * WA_MARM2-UMREZ / WA_MARM2-UMREN.
TP_DATA-KHETR = TP_DATA-KBETR * '1.17'.
ENDIF.
ELSEIF TP_DATA-KSCHL = 'ZPR3'.
* TP_DATA-KSCHL = 'B2'.
IF TP_DATA-KMEIN = 'ZI'.
TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
ELSE.
READ TABLE IT_MARM INTO WA_MARM1 WITH KEY MATNR = TP_DATA-MATNR MEINH = TP_DATA-KMEIN.
* READ TABLE IT_MARM INTO WA_MARM2 WITH KEY MATNR = TP_DATA-MATNR MEINH = 'BAG'.
TP_DATA-KHETR = TP_DATA-KHETR * WA_MARM1-UMREN / WA_MARM1-UMREZ.
* * WA_MARM2-UMREZ / WA_MARM2-UMREN.
TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
ENDIF.
ENDIF.
TP_DATA-MEINH = '01'.
MODIFY TP_DATA.
E_T_DATA-MATNR = TP_DATA-MATNR.
E_T_DATA-KSCHL = TP_DATA-KSCHL.
E_T_DATA-KHETR = TP_DATA-KHETR.
E_T_DATA-KBETR = TP_DATA-KBETR.
E_T_DATA-KMEIN = TP_DATA-KMEIN.
E_T_DATA-DATAB = TP_DATA-DATAB.
E_T_DATA-DATBI = TP_DATA-DATBI.
APPEND E_T_DATA.
CLEAR WA_MARM1.
CLEAR WA_MARM2.
ENDLOOP.
Edited by: Shen Peng on Oct 20, 2010 10:09 AM -
Uncatchable exception: BSP calling Function Module
Hi all,
currently i'm facing a very weird problem. My application class calls function module
HR_INFOTYPE_OPERATION. Normally, in case of an error, the function module gives you back a return parameter. But if i call it from my BSP, the processing doesn't leave the function module. It directly throws an exception ERROR_MESSAGE_STATE instead of writing the message into parameter return.
If i call the function module with the same parameters from a report, it works fine and the error message is written to return parameter without throwing an exception.
What am i doing wrong? I don't want that exception and need to go on with filled parameter result.
Regards
Mark-AndréHi MA,
try using ERROR_MESSAGE in the exceptions list, like this.
CALL FUNCTION 'func_name'
EXPORTING
string = text
pos = position
IMPORTING
string1 = text1
string2 = text2
EXCEPTIONS
string1_too_small = 1
string2_too_small = 2
ERROR_MESSAGE = 3
OTHERS = 4.
Cheers
Graham Robbo -
Function module called within a loop seems to carry over global data
Hello all,
I am calling FM "RS_COVERPAGE_SELECTIONS" inside of a loop of all variants for a program and then writing the variant values to spool. If only one variant is entered on the selection screen, all the values are correct. If nothing is entered, some of the variant values are carried over from a previous variant. I am emptying the internal table returned by the FM every time before the FM executes.
Would some one be willing to run the following code for a program with many screen fields and many variants and tell me if they get the same behavior?
Thanks
Bruce
REPORT zzzz.
tables: varid, varit.
parameters: p_pgm type progname obligatory default 'ZFAPI004'.
select-options: s_var for varid-variant.
parameters: p_varval as checkbox default 'X'.
data: begin of reptab occurs 0,
report like varid-report,
variant like varid-variant,
ename like varid-ename,
edat like varid-edat,
etime like varid-etime,
aename like varid-aename,
aedat like varid-aedat,
aetime like varid-aetime,
vtext like varit-vtext,
end of reptab.
data: begin of tab_sel_options occurs 0,
flag(1) type c,
olength type x,
line like rsvar-infoline,
end of tab_sel_options.
*>> At Selection-Screen data items <<
data: w_pgm like sy-repid.
data: itab like rseui_f4 occurs 0 with header line.
data: dyname like d020s-prog value sy-repid,
dynumb like d020s-dnum value '1000'.
data: begin of dynpfields occurs 3.
include structure dynpread.
data: end of dynpfields.
data: w_tabix like sy-tabix.
data: begin of i_var occurs 0,
variant like varit-variant,
vtext like varit-vtext.
data: end of i_var.
start-of-selection.
format intensified on.
write: / p_pgm.
select * from varid
where report = p_pgm
and variant in s_var.
select single * from varit
where langu = 'E' and report = p_pgm
and variant = varid-variant.
move-corresponding varid to reptab.
move-corresponding varit to reptab.
append reptab.
endselect.
sort reptab by variant.
skip 1.
format color col_heading.
write: /03 'Variant',
18 'Create',
47 'Modify',
76 'Description'.
format color off.
skip 2.
loop at reptab.
format color col_total.
write: /3 reptab-variant,
reptab-ename(8),
reptab-edat,
reptab-etime,
reptab-aename(8),
reptab-aedat,
reptab-aetime,
reptab-vtext.
format color off.
skip 1.
if p_varval = 'X'.
clear tab_sel_options. " header
refresh tab_sel_options. " lines
call function 'RS_COVERPAGE_SELECTIONS'
exporting
report = reptab-report
variant = reptab-variant
no_import = ' '
tables
infotab = tab_sel_options
exceptions
error_message = 1
variant_not_found = 2
others = 3.
loop at tab_sel_options.
if sy-tabix < 7.
continue.
endif.
write: / tab_sel_options-line.
endloop.
skip 1.
endif. " p_varval = 'X'.
endloop.Hi
Try using the function module PRINT_SELECTIONS, within this FM, the FM RS_COVERPAGE_SELECTIONS is being called. So it will not copy the previous values.
Pass Mode as 'A' , report name and variant name, then it will display the same output.
Please try it
Shiva -
I am trying to use PHP and SAPRFC to pull out some information from our SAP database. I've been reading documentation and I've stumbled across this in the SAP documentation:
There are two restrictions on writing remote functions that are to be called transactionally:
+ Transactional calls cannot return parameter values. As a result, the interface for these functions should not specify any EXPORT parameters.
+ Functions that run transactionally may not perform call-backs: the caller's context does not necessarily still exist when the call-back is relayed back to the original system.
If this is true then how am I suppose to receive any data back from the RFC? I am trying to pull a couple of variables out of a few tables using basic select statements like this:
FUNCTION Z_RFC_COMMISSION_INDIVIDUAL.
*"*"Local Interface:
*" IMPORTING
*" VALUE(COMM_ACCOUNT) TYPE LIFNR DEFAULT 000000
*" EXPORTING
*" VALUE(NAME) TYPE LFA1-NAME1
SELECT SINGLE name1 FROM lfa1 INTO name
WHERE lifnr = comm_account.
ENDFUNCTION.
I can connect to the SAP database but I am still not clear on the best way to pull out single values instead of a whole table from SAP using PHP. Does anyone have any example function module source code they could share?Hi Mark,
I used this code (copy of you)
DATA: comm_info_output TYPE TABLE OF bdi_entry.
DATA: comm_info TYPE TABLE OF lfa1.
DATA: nametab TYPE TABLE OF bdi_mfgrp.
DATA: sel_tab TYPE TABLE OF bdsel_stat.
CALL FUNCTION 'TABLE_ENTRIES_GET_VIA_RFC'
EXPORTING
tabname = 'LFA1'
TABLES
tabentry = comm_info_output
nametab = nametab
sel_tab = sel_tab
EXCEPTIONS
system_failure = 1 MESSAGE l_mes
communication_failure = 2
OTHERS = 3.
comm_info[] = comm_info_output[].
and I get no error message. Where exactly do you get error message. Resp. is it going to short dump? (if so please attach list from st22).
I think the problem is not in function module but in setting of unicode / non unicode systems. Probably with FM you get some not allowed characters.
I found following thread:
RFC Lookup after unicode conversion of target R/3
Is it suitable for you?
Sorry I am not expert for this. Maybe if you identify exact problem and you don't know solution create a new thread with good description in the title and you will find unicode issues experts.
Regards,
Karol
Edited by: Karol Seman on Jul 30, 2008 2:18 PM -
A FUNCTION MODULE FOR THE HR MODULE FOR PAYROLL OF EMPLOYEES
hi,
i want some a function module or code where i need to get the payroll details like the basic pay ,hra,special allowance,medical allowance,other allowance of an employee on the monthly basis.
the data that i have on ot os not on the basis of months it contains datd of more than one month.like the baisc pay of an employee is given on a radom day basis of more than one month.
but i need to bifercatethe data on monthly basis.
waiting for the reply.
thanks and regardsHi,
Use the fun module
RP_FILL_WAGE_TYPE_TABLE_EXT
which willget PA0008 results.
but to get the real payroll results you have to import data from clusters by writing the program. Data will be fetch from RT and CRT internal tables based on the Wage Types
see the sample code:
report zporgr0100
line-size 252
line-count 60(1)
no standard page heading
message-id zndc.
Database Tables & Infotypes
tables: pcl1, " HR Cluster1
pcl2, " HR Cluster1
pa0003, " Master data - Payroll Status
cskt, " Cost Center Texts
t528t, " Positions Texts
t513s, " Job Titles
pernr, " Logical PNP
t001p, " Personnel Subarea
t500p, " Personnel Area
t501, " Employee Group
t503k, " Employee Subgroup
csks. " Cost Center
infotypes:0000,0001.
*include rpclst00.
include rpc2rx00.
include rpc2rxx0.
include rpc2cd00.
*include rpc2ps00.
*include rpc2pt00.
*include rpcfvp00.
*include rpcfdc10.
*include rpcfdc00.
include rpppxd00.
include rpppxd10.
Declaration of Internal Tables
Internal Table for Output Data
data: begin of rep_tab occurs 0,
kostl like pa0001-kostl, " Cost Center
pernr like pa0001-pernr, " Personal Number
ename like pa0001-ename, " Employee Name
ctext like cskt-ltext, " Cost Center Text
ptext like t528t-plstx, " Position Text
ot1 type p decimals 2, " Jan OT Amount
ot2 type p decimals 2, " Feb OT Amount
ot3 type p decimals 2, " Mar OT Amount
ot4 type p decimals 2, " Apr OT Amount
ot5 type p decimals 2, " May OT Amount
ot6 type p decimals 2, " Jun OT Amount
ot7 type p decimals 2, " Jul OT Amount
ot8 type p decimals 2, " Aug OT Amount
ot9 type p decimals 2, " Sep OT Amount
ot10 type p decimals 2, " Oct OT Amount
ot11 type p decimals 2, " Nov OT Amount
ot12 type p decimals 2, " Dec OT Amount
ott type p decimals 2, " Total OT Amount
end of rep_tab.
Declaration of Variables
data: v_mon(2) type n, " Month
v_no type i, " Data Lines
v_year(4) type c, " Year
v_date like sy-datum, " Date
v_date1 like sy-datum, " Date
v_seqnr like pc261-seqnr. " Sequence No.
Declaration of Constants
data: c_type like hrp1001-otype value 'S', " Object Type
c_kokrs like cskt-kokrs value '1000', " Controlling Area
c_date1 like sy-datum value '18000101', " Date
c_date2 like sy-datum value '99991231', " Date
c_x type c value 'X', " Sign
c_mon(2) type c value '01', " Month
c_val1(2) type c value '31', " Date
c_val2(2) type c value '12', " Month Type
c_val like p0041-dar01 value '01', " Date Type
c_lgart1 like p0008-lga01 value '0722', " Wage Type
c_lgart2 like p0008-lga01 value '0723', " Wage Type
c_1(2) type n value '01', " Month1
c_2(2) type n value '02', " Month2
c_3(2) type n value '03', " Month3
c_4(2) type n value '04', " Month4
c_5(2) type n value '05', " Month5
c_6(2) type n value '06', " Month6
c_7(2) type n value '07', " Month7
c_8(2) type n value '08', " Month8
c_9(2) type n value '09', " Month9
c_10(2) type n value '10', " Month10
c_11(2) type n value '11', " Month11
c_12(2) type n value '12'. " Month12
Selection-screen
parameters:
p_year like pc2b0-pabrj obligatory. " Payroll Year
At selection-screen
at selection-screen.
Validate the Selection Screen fields
perform validate_screen.
Start-of-Selection
start-of-selection.
Selection of Period
perform get_period.
Get PERNR from LDB
get pernr.
Get the Master data from infotype 0001
perform get_master_data.
Top-of-page
top-of-page.
Write the Report and Column Headings
perform top_of_page.
End-of-Page
end-of-page.
write /1(252) sy-uline.
End-of-Selection
end-of-selection.
Display the Output Report.
perform display_report.
Form-Routines
*& Form validate_screen
Validation of selection Screen fields
form validate_screen.
Validation of Cost Center
clear csks.
if not pnpkostl[] is initial.
select single kostl
into csks-kostl
from csks
where kostl in pnpkostl.
if sy-subrc <> 0.
message e999 with 'Invalid Cost Center'(003).
endif.
endif.
Validation of Personnel Number
clear pa0003.
if not pnppernr[] is initial.
select pernr
from pa0003 up to 1 rows
into pa0003-pernr
where pernr in pnppernr.
endselect.
if sy-subrc <> 0.
message e999 with 'Incorrect Personal Number Entered'(002).
endif.
endif.
Validation of Personnel Area
clear t500p.
if not pnpwerks[] is initial.
select persa
from t500p up to 1 rows
into t500p-persa
where persa in pnpwerks.
endselect.
if sy-subrc <> 0.
message e999 with 'Incorrect Personnel Area Entered'(001).
endif.
endif.
Validation of Personnel Sub Area
clear t001p.
if not pnpbtrtl[] is initial.
select btrtl
from t001p up to 1 rows
into t001p-btrtl
where btrtl in pnpbtrtl.
endselect.
if sy-subrc <> 0.
message e999 with 'Incorrect Personnel Sub Area Entered'(037).
endif.
endif.
Validation of Employee Group
clear t501.
if not pnppersg[] is initial.
select persg
from t501 up to 1 rows
into t501-persg
where persg in pnppersg.
endselect.
if sy-subrc <> 0.
message e999 with 'Incorrect Employee Group Entered'(038).
endif.
endif.
Validation of Employee Sub Group
clear t503k.
if not pnppersk[] is initial.
select persk
from t503k up to 1 rows
into t503k-persk
where persk in pnppersk.
endselect.
if sy-subrc <> 0.
message e999 with 'Incorrect Employee Sub Group Entered'(039).
endif.
endif.
endform. "validate_screen
*& Form get_period
Get the Correct Period based on Selection screen selection
form get_period.
clear: v_year,v_mon, v_date, v_date1.
v_year = sy-datum+0(4).
v_mon = sy-datum+4(2).
if pnptimr1 = c_x. " Current Date
pnpbegda = sy-datum.
pnpendda = sy-datum.
elseif pnptimr2 = c_x. " Current Month
concatenate v_year v_mon c_val into v_date.
concatenate v_year v_mon c_val1 into v_date1.
pnpbegda = v_date.
pnpendda = v_date1.
elseif pnptimr3 = c_x. " Current Year
concatenate v_year c_val c_val into v_date.
concatenate v_year c_val2 c_val1 into v_date1.
pnpbegda = v_date.
pnpendda = v_date1.
elseif pnptimr4 = c_x. " Upto Today
pnpbegda = c_date1.
pnpendda = sy-datum.
elseif pnptimr5 = c_x. " From Today
pnpbegda = sy-datum.
pnpendda = c_date2.
else.
if ( pnpbegda is initial and pnpendda is initial ).
pnpbegda = c_date1.
pnpendda = c_date2.
elseif pnpbegda is initial and not pnpendda is initial.
pnpbegda = c_date1.
pnpendda = pnpendda.
elseif not ( pnpbegda is initial and pnpendda is initial ).
pnpbegda = pnpbegda.
pnpendda = pnpendda.
endif.
endif.
endform. "get_period
*& Form get_master_data
Get the Master Data from Database Tables PA0001,0002,0003
form get_master_data.
Get data from Respective Infotypes
rp_provide_from_last p0001 space pnpbegda pnpendda.
if p0001-kostl in pnpkostl.
rep_tab-kostl = p0001-kostl.
rep_tab-pernr = p0001-pernr.
rep_tab-ename = p0001-ename.
Get the Position Text
clear t528t-plstx.
select single plstx into t528t-plstx from t528t
where plans = p0001-plans and
otype = c_type and
sprsl = sy-langu.
if sy-subrc = 0.
rep_tab-ptext = t528t-plstx.
endif.
Get the Cost Center Text
clear cskt-ltext.
select single ltext into cskt-ltext from cskt
where spras = sy-langu and
kokrs = c_kokrs and
kostl = p0001-kostl.
if sy-subrc = 0.
rep_tab-ctext = cskt-ltext.
endif.
Get the Overtime Payment Data
perform get_ot_data.
rep_tab-ott = rep_tab-ot1 + rep_tab-ot2 + rep_tab-ot3 +
rep_tab-ot4 + rep_tab-ot5 + rep_tab-ot6 +
rep_tab-ot7 + rep_tab-ot8 + rep_tab-ot9 +
rep_tab-ot10 + rep_tab-ot11 + rep_tab-ot12.
append rep_tab.
clear rep_tab.
endif.
sort rep_tab by kostl pernr.
delete rep_tab where kostl = ' '.
delete rep_tab where ott = 0.
endform. "get_master_data
*& Form get_ot_data
Get the Overtime Payment Data
form get_ot_data.
cd-key = pernr-pernr.
rp-imp-c2-cd.
sort rgdir by seqnr.
To get sequence number for the payroll period
loop at rgdir where void is initial
and reversal is initial
and outofseq is initial
and srtza eq 'A'.
if rgdir-fpper+0(4) = p_year.
To consider offcycle run data
if not rgdir-ocrsn is initial.
v_seqnr = rgdir-seqnr.
exit.
endif.
v_seqnr = rgdir-seqnr.
endif.
if not v_seqnr is initial.
perform import_rx.
endif.
perform process_wagetypes.
endloop.
endform. "get_ot_data
include rpppxm00.
*& Form Import_rx
Import the RX data from Clusters
form import_rx.
rx-key-pernr = cd-key-pernr.
rx-key-seqno = v_seqnr.
rp-init-buffer.
rp-imp-c2-rx.
endform. " Import_rx
*& Form Process_wagetypes
Calculate the Overtime Amount based on Wage types
form process_wagetypes.
loop at rt.
if rt-lgart = c_lgart1 or rt-lgart = c_lgart2.
if rgdir-fpper+0(4) = p_year.
v_mon = rgdir-fpper+4(2).
case v_mon .
when c_1.
rep_tab-ot1 = rep_tab-ot1 + rt-betrg.
when c_2.
rep_tab-ot2 = rep_tab-ot2 + rt-betrg.
when c_3.
rep_tab-ot3 = rep_tab-ot3 + rt-betrg.
when c_4.
rep_tab-ot4 = rep_tab-ot4 + rt-betrg.
when c_5.
rep_tab-ot5 = rep_tab-ot5 + rt-betrg.
when c_6.
rep_tab-ot6 = rep_tab-ot6 + rt-betrg.
when c_7.
rep_tab-ot7 = rep_tab-ot7 + rt-betrg.
when c_8.
rep_tab-ot8 = rep_tab-ot8 + rt-betrg.
when c_9.
rep_tab-ot9 = rep_tab-ot9 + rt-betrg.
when c_10.
rep_tab-ot10 = rep_tab-ot10 + rt-betrg.
when c_11.
rep_tab-ot11 = rep_tab-ot11 + rt-betrg.
when c_12.
rep_tab-ot12 = rep_tab-ot12 + rt-betrg.
endcase.
endif.
endif.
endloop.
endform. "process_wagetypes
*& Form top_of_page
Write the Report and Column Headings
form top_of_page.
format color col_heading on.
write: /1(252) 'NATIONAL DRILLING COMPANY'(010) centered,
/1(252) 'Overtime Payments Details'(011) centered.
format color off.
if pnptimr1 = c_x. " Current Date
write: /2 'Period From :'(036), sy-datum, 'To:'(006), sy-datum.
elseif pnptimr2 = c_x. " Current Month
write: /2 'Period From :'(036), v_date, 'To:'(006), v_date1.
elseif pnptimr3 = c_x. " Current Year
write: /2 'Period From :'(036), v_date, 'To:'(006), v_date1.
elseif pnptimr4 = c_x. " Upto Today
write: /2 'Period From :'(036), c_date1, 'To:'(006), sy-datum.
elseif pnptimr5 = c_x. " From Today
write: /2 'Period From :'(036), sy-datum, 'To:'(006), c_date2.
else.
if ( pnpbegda is initial and pnpendda is initial ).
write: /2 'Period From :'(036), c_date1, 'To:'(006), c_date2.
elseif pnpbegda is initial and not pnpendda is initial.
write: /2 'Period From :'(036), c_date1, 'To:'(006), pnpendda.
elseif not ( pnpbegda is initial and pnpendda is initial ).
write: /2 'Period From :'(036), pnpbegda,
'To:'(006), pnpendda.
endif.
endif.
write: 219 'Report Run Date:'(018), sy-datum.
if not pnpkostl[] is initial.
if pnpkostl-high is initial.
write: /2 'Cost Center :'(004), pnpkostl-low,
219 'Time :'(020), sy-uzeit.
else.
write: /2 'Cost Center From:'(005), pnpkostl-low+7(3),
'To:'(006), pnpkostl-high,
219 'Time :'(020), sy-uzeit.
endif.
else.
write: /219 'Time :'(020), sy-uzeit.
endif.
if not pnppernr[] is initial.
if pnppernr-high is initial.
write: /2 'Personal Number :'(007), pnppernr-low,
219 'User :'(021), sy-uname.
else.
write: /2 'Personal No.From:'(008), pnppernr-low,
'To:'(006), pnppernr-high,
219 'User :'(021), sy-uname.
endif.
else.
write: /219 'User :'(021), sy-uname.
endif.
write: /219 'Page No :'(022), sy-pagno.
format color col_heading.
write /1(252) sy-uline.
write:/1 sy-vline, 10 sy-vline,
41 sy-vline,
67 sy-vline, 68(167) 'Overtime Payments(Dirhams)'(013) centered,
235 sy-vline,252 sy-vline.
format color col_heading.
write:/1 sy-vline, 2(8) 'Emp #'(019) centered,
10 sy-vline, 11(30) 'Employee Name'(012) centered,
41 sy-vline, 42(25) 'Position'(014) centered,
67 sy-vline, 68(167) sy-uline,
235 sy-vline,236(16) 'Total'(017) centered,
252 sy-vline.
write:/1 sy-vline, 10 sy-vline,
41 sy-vline,
67 sy-vline, 68(13) 'JANUARY'(024) centered,
81 sy-vline, 82(13) 'FEBRUARY'(025) centered,
95 sy-vline, 96(13) 'MARCH'(026) centered,
109 sy-vline,110(13) 'APRIL'(027) centered,
123 sy-vline,124(13) 'MAY'(028) centered,
137 sy-vline,138(13) 'JUNE'(029) centered,
151 sy-vline,152(13) 'JULY'(030) centered,
165 sy-vline,166(13) 'AUGUST'(031) centered,
179 sy-vline,180(13) 'SEPTEMBER'(032) centered,
193 sy-vline,194(13) 'OCTOBER'(033) centered,
207 sy-vline,208(13) 'NOVEMBER'(034) centered,
221 sy-vline,222(13) 'DECEMBER'(035) centered,
235 sy-vline,252 sy-vline.
format color off.
write /1(252) sy-uline.
endform. "top_of_page
*& Form Display_report
Write the Report Output
form display_report.
clear v_no.
describe table rep_tab lines v_no.
if v_no = 0.
message i999 with
'No Data found for the entered Selection'(015).
endif.
loop at rep_tab.
format color 3.
at new kostl.
read table rep_tab index sy-tabix.
write:/1 sy-vline, 2(12) 'Cost Center:'(009),
14(10) rep_tab-kostl,
25(30) rep_tab-ctext,
252 sy-vline.
format color off.
write /1(252) sy-uline.
endat.
format color col_normal.
write: /1 sy-vline, 2(8) rep_tab-pernr,
10 sy-vline, 11(30) rep_tab-ename,
41 sy-vline, 42(25) rep_tab-ptext,
67 sy-vline, 68(13) rep_tab-ot1 no-zero,
81 sy-vline, 82(13) rep_tab-ot2 no-zero,
95 sy-vline, 96(13) rep_tab-ot3 no-zero,
109 sy-vline,110(13) rep_tab-ot4 no-zero,
123 sy-vline,124(13) rep_tab-ot5 no-zero,
137 sy-vline,138(13) rep_tab-ot6 no-zero,
151 sy-vline,152(13) rep_tab-ot7 no-zero,
165 sy-vline,166(13) rep_tab-ot8 no-zero,
179 sy-vline,180(13) rep_tab-ot9 no-zero,
193 sy-vline,194(13) rep_tab-ot10 no-zero,
207 sy-vline,208(13) rep_tab-ot11 no-zero,
221 sy-vline,222(13) rep_tab-ot12 no-zero,
235 sy-vline,236(16) rep_tab-ott no-zero,
252 sy-vline.
at end of kostl.
write /1(252) sy-uline.
endat.
format color off.
at last.
sum.
format color 1.
write: /1 sy-vline,
10 sy-vline, 11(30) 'Total'(017) centered,
41 sy-vline,
67 sy-vline, 68(13) rep_tab-ot1 no-zero,
81 sy-vline, 82(13) rep_tab-ot2 no-zero,
95 sy-vline, 96(13) rep_tab-ot3 no-zero,
109 sy-vline,110(13) rep_tab-ot4 no-zero,
123 sy-vline,124(13) rep_tab-ot5 no-zero,
137 sy-vline,138(13) rep_tab-ot6 no-zero,
151 sy-vline,152(13) rep_tab-ot7 no-zero,
165 sy-vline,166(13) rep_tab-ot8 no-zero,
179 sy-vline,180(13) rep_tab-ot9 no-zero,
193 sy-vline,194(13) rep_tab-ot10 no-zero,
207 sy-vline,208(13) rep_tab-ot11 no-zero,
221 sy-vline,222(13) rep_tab-ot12 no-zero,
235 sy-vline,236(16) rep_tab-ott no-zero,
252 sy-vline.
write /1(252) sy-uline.
endat.
format color off.
endloop.
endform. "display_report
reward points if useful
regards,
Anji -
Help in IDOC_INPUT_ORDERS Function module
Hi,
I am writing a program to generate an IDOC using IDOC_INPUT_ORDERS Function module .
But I am a little confused as to what has to be passed as input_method,mass_processing which are the import parameters of this function-module .
If anyone has a sample code program using function module IDOC_INPUT_ORDERS , please could you share it with me .
Regards,
Sushanth H.S.Hi Sushanth,
IDOC_INPUT_ORDERS is a posting program.
This program uploads the idic to the database table.
Thatis it converts the idoc format to the SAP format.
I have created a sample posting program.
Please go through it.
*& Report Z_FI_UTIL_EXCEL2GL_POSTING *
REPORT Z_FI_UTIL_EXCEL2GL_POSTING.
include <icon>.
*/ =================================================================== *
CONSTANTS: on VALUE 'X',
off VALUE ' ',
tabx TYPE X VALUE '09',
c_e1bpache08 TYPE edilsegtyp VALUE 'E1BPACHE08',
c_e1bpacgl08 TYPE edilsegtyp VALUE 'E1BPACGL08',
c_e1bpaccr08 TYPE edilsegtyp VALUE 'E1BPACCR08'.
TYPES: BEGIN OF t_tab_index,
from TYPE i,
to TYPE i,
END OF t_tab_index.
data : tab type c.
DATA:
e1bpache08 LIKE e1bpache08,
e1bpacgl08 LIKE e1bpacgl08,
e1bpaccr08 LIKE e1bpaccr08.
DATA: g_subrc TYPE subrc.
DATA: g_file TYPE string.
DATA: g_segname TYPE edilsegtyp.
DATA: g_sdata TYPE edi_sdata.
DATA: g_first_doc.
DATA: i_dataf TYPE char2000 OCCURS 900 WITH HEADER LINE,
i_dataf_doc TYPE char2000 OCCURS 50 WITH HEADER LINE.
DATA: g_tab_index TYPE t_tab_index OCCURS 100 WITH HEADER LINE.
DATA: i_accountgl TYPE bapiacgl08 OCCURS 100 WITH HEADER LINE,
i_curramnt TYPE bapiaccr08 OCCURS 100 WITH HEADER LINE,
i_return TYPE bapiret2 OCCURS 10 WITH HEADER LINE,
g_docheader TYPE bapiache08.
*/ ======================== SELECTION ================================ *
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-010.
PARAMETERS: excelf TYPE file_name LOWER CASE
DEFAULT 'C:\my_excel_file.txt'.
SELECTION-SCREEN END OF BLOCK b1.
*/ =========================== CORE ================================== *
START-OF-SELECTION.
*/ Call text File with GUI_UPLOAD
g_file = excelf.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = g_file
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
IMPORTING
FILELENGTH =
HEADER =
TABLES
data_tab = i_dataf
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17
IF sy-subrc <> 0.
write: / Text-032.
stop.
ENDIF.
*/ Initialisation
write tabx to tab. " required as of ABAP 610 split cannot
*/ have mixed char and byte types
CLEAR g_tab_index.
REFRESH g_tab_index.
*/ how to process several doc : detecting docs in i_dataf
g_first_doc = on.
LOOP AT i_dataf.
CLEAR: g_segname, g_sdata.
SPLIT i_dataf AT tab INTO g_segname g_sdata.
CHECK: g_segname = c_e1bpache08,
sy-tabix > 1.
*/ 1st document
IF g_first_doc = on.
g_tab_index-from = 1.
g_tab_index-to = sy-tabix - 1.
APPEND g_tab_index.
*/ Next Documents
ELSE.
g_tab_index-from = g_tab_index-to + 1.
g_tab_index-to = sy-tabix - 1.
APPEND g_tab_index.
ENDIF.
g_first_doc = off.
ENDLOOP.
*/ Last doc.
g_tab_index-from = g_tab_index-to + 1.
g_tab_index-to = sy-tfill.
APPEND g_tab_index.
*/ Process documents.
loop at g_tab_index.
clear i_dataf_doc.
refresh i_dataf_doc.
append lines of i_dataf from g_tab_index-from
to g_tab_index-to
to i_dataf_doc.
perform process_document.
endloop.
END-OF-SELECTION.
*/ =========================== ROUTINES ============================== *
FORM process_document *
FORM process_document.
*/ Clearing Memory
CLEAR: g_docheader, i_accountgl, i_curramnt, i_return, g_subrc.
REFRESH: i_accountgl, i_curramnt, i_return.
*/ Checking i_dataf_doc
*/ Mapping dataf => Bapi structures & internal tables
CLEAR g_subrc.
CATCH SYSTEM-EXCEPTIONS conversion_errors = 1.
LOOP AT i_dataf_doc.
CLEAR g_sdata.
SPLIT i_dataf_doc AT tab INTO g_segname g_sdata.
CASE g_segname.
*/ HEADER
WHEN c_e1bpache08.
PERFORM do_split_ache08.
MOVE-CORRESPONDING e1bpache08 TO g_docheader.
IF e1bpache08-doc_date IS INITIAL.
CLEAR g_docheader-doc_date.
ENDIF.
IF e1bpache08-pstng_date IS INITIAL.
CLEAR g_docheader-pstng_date.
ENDIF.
IF e1bpache08-trans_date IS INITIAL.
CLEAR g_docheader-trans_date.
ENDIF.
*/ Account GL
WHEN c_e1bpacgl08.
PERFORM do_split_acgl08.
MOVE-CORRESPONDING e1bpacgl08 TO i_accountgl.
IF e1bpacgl08-pstng_date IS INITIAL.
CLEAR i_accountgl-pstng_date.
ENDIF.
APPEND i_accountgl.
*/ Account Currency & Amounts
WHEN c_e1bpaccr08.
PERFORM do_split_accr08.
MOVE-CORRESPONDING e1bpaccr08 TO i_curramnt.
APPEND i_curramnt.
*/ kick the line if segment name not filled
WHEN space.
*/ Other names => Bad file structure !
WHEN OTHERS.
g_subrc = 2.
ENDCASE.
ENDLOOP. " i_dataf_doc
ENDCATCH.
*/ erreur d'affectation
IF sy-subrc = 1 OR
NOT g_subrc IS INITIAL.
perform message_output using on.
exit.
ENDIF.
*/ Calling the BAPI
CALL FUNCTION 'BAPI_ACC_GL_POSTING_POST'
EXPORTING
documentheader = g_docheader
IMPORTING
OBJ_TYPE =
OBJ_KEY =
OBJ_SYS =
TABLES
accountgl = i_accountgl
currencyamount = i_curramnt
return = i_return
EXTENSION1 =
LOOP AT i_return WHERE type CA 'AE'.
g_subrc = 1.
EXIT.
ENDLOOP.
IF NOT g_subrc IS INITIAL.
perform message_output using on.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
RETURN =
perform message_output using off.
ENDIF.
ENDFORM.
*& Form do_split_ACHE08
text
--> p1 text
<-- p2 text
FORM do_split_ache08.
CLEAR e1bpache08.
SPLIT g_sdata AT tab INTO
e1bpache08-obj_type
e1bpache08-obj_key
e1bpache08-obj_sys
e1bpache08-username
e1bpache08-header_txt
e1bpache08-obj_key_r
e1bpache08-comp_code
e1bpache08-ac_doc_no
e1bpache08-fisc_year
e1bpache08-doc_date
e1bpache08-pstng_date
e1bpache08-trans_date
e1bpache08-fis_period
e1bpache08-doc_type
e1bpache08-ref_doc_no
e1bpache08-compo_acc
e1bpache08-reason_rev
ENDFORM. " do_split_ACHE08
*& Form do_split_ACGL08
text
--> p1 text
<-- p2 text
FORM do_split_acgl08.
CLEAR e1bpacgl08.
SPLIT g_sdata AT tab INTO
e1bpacgl08-itemno_acc
e1bpacgl08-gl_account
e1bpacgl08-comp_code
e1bpacgl08-pstng_date
e1bpacgl08-doc_type
e1bpacgl08-ac_doc_no
e1bpacgl08-fisc_year
e1bpacgl08-fis_period
e1bpacgl08-stat_con
e1bpacgl08-ref_key_1
e1bpacgl08-ref_key_2
e1bpacgl08-ref_key_3
e1bpacgl08-customer
e1bpacgl08-vendor_no
e1bpacgl08-alloc_nmbr
e1bpacgl08-item_text
e1bpacgl08-bus_area
e1bpacgl08-costcenter
e1bpacgl08-acttype
e1bpacgl08-orderid
e1bpacgl08-orig_group
e1bpacgl08-cost_obj
e1bpacgl08-profit_ctr
e1bpacgl08-part_prctr
e1bpacgl08-wbs_element
e1bpacgl08-network
e1bpacgl08-routing_no
e1bpacgl08-order_itno
ENDFORM. " do_split_ACGL08
*& Form do_split_ACCR08
text
--> p1 text
<-- p2 text
FORM do_split_accr08.
data: l_filler(100).
CLEAR e1bpaccr08.
SPLIT g_sdata AT tab INTO
e1bpaccr08-itemno_acc
e1bpaccr08-curr_type
e1bpaccr08-currency
e1bpaccr08-currency_iso
e1bpaccr08-amt_doccur
e1bpaccr08-exch_rate
e1bpaccr08-exch_rate_v
l_filler
ENDFORM. " do_split_ACCR08
*& Form message_output
text
--> p1 text
<-- p2 text
FORM message_output using if_error.
data: l_message(200),
l_return type i.
format color 1.
skip.
write: / text-020, g_tab_index-from,
text-021, g_tab_index-to.
skip.
if if_error = on.
write: / icon_red_light as icon, text-030 color 6.
else.
write: / icon_green_light as icon, text-031 color 5.
endif.
describe table i_return lines l_return.
if l_return is initial.
write: / text-032.
endif.
loop at i_return.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = i_return-id
LANG = sy-langu
NO = i_return-number
V1 = i_return-MESSAGE_V1
V2 = i_return-MESSAGE_V2
V3 = i_return-MESSAGE_V3
V4 = i_return-MESSAGE_V4
IMPORTING
MSG = l_message
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2
check sy-subrc = 0.
write: / l_message.
endloop.
ENDFORM. " message_output
Tell me ur mailid. I will sen u more.
<b>Please reward if helpful.</b> -
MySAP replacements for Excel upload function modules?
I am doing some development in SRM 4.0 (WAS 640) and I notice that a few of my favorite function modules are no longer available. Specifically, I'm missing these the most:
KCD_EXCEL_OLE_TO_INT_CONVERT
ALSM_EXCEL_TO_INTERNAL_TABLE
Are there new equivalents? I know how to access XLS files by writing my own OLE calls, but sometimes it's just easier to use the standard function modules instead.
Yes, I've done a function module search, but I've found nothing that looks to the the same as my old friends.Hi Chris,
I can't give you an alternative function module per say. Obviously, the downside of using SAP functions, that were probably never released for customer consumption anyway is that they can easily disappear. The suggestion I have is to use the features offered by DOI (desktop office integration). There in lies a set of classes and methods for generically accessing various documents (e.g. ms word, excel etc.) There is some examples in the re-use library (tcode se83). So here you don't need to be worried about the OLE either. Possibly in WAS there might also be some other classes that might access Excel sheets. Downside of finding a new function is that it might disappear in the next version you go to, whereas DOI is unlikey to disappear in a hurry. Best of luck.
p.s. there are a few other postings in the forum, maybe one will give you an answer, if you haven't search already.
Message was edited by: Michael Bennett -
Third party system call function module/BAPI through RFC to update Z table
Dear Friends,
We have a third party system which directly inserts a Z table in SAP through its programming, which is an auditing issue.
We want the third party system should call function module/BAPI through RFC so that the Z table gets updated.
waiting for inputs..
Thanks,
Kumarif third party system is capable of making Remote Function call, then writing a Function module & making it remote enable is not difficult task in ABAP.
You may have to prepare specifications first to decide if third party system is going to Read, insert, update, delete records from Zee table. -
Function Module to Calculate Due Date from Payment Terms?
I'm writing an aged debtor report as the SAP standard one isn't quite right for our requirements. Is there a function module that will calculate the payment due date if I give it the payment terms and the base line date?
I did a search in SE37 but couldn't see one which fitted my requirements (I was searching on CALCDUEDATE and variantions of).
Any suggestions welcome, thanks.
GillHi,
Use the FM FI_TERMS_OF_PAYMENT_PROPOSE for calculating the Payment due date
call function 'FI_TERMS_OF_PAYMENT_PROPOSE'
exporting
i_bldat = gv_bldat
i_budat = gv_budat
i_cpudt = sy-datum
i_zfbdt = gv_zfbdt
i_zterm = gv_terms_paym
i_bukrs = gv_comp_code
importing
e_zbd1t = gv_zbd1t
e_zbd1p = gv_zbd1p
e_zbd2t = gv_zbd2t
e_zbd3t = gv_zbd3t.
Regards,
Dwaraka.S -
Is there a Function module to get customer hierarchy data?
Howdy,
I'm writing a report where the user can, on the selection screen, enter a customer number or a hierarchy node and then the program has to get all the higher level nodes and and lower level nodes for the selected Sales area.
eg. for the following hierarchy:
A
->B
--|-> D
--|-> E
-> C
---|-> F
---|-> G
if node b was selected it would pull back:
KUNNR HKUNNR
A blank
B A
C A
D B
E B
F C
G C
Anyone know if there is a Function module that can do this?
ThanksHi Victoria,
even i was using the same FM "RSNDI_SHIE_STRUCTURE_GET3"
my code goes like this...
i am passing hierarchy name and node name...this is for cost element hierarchy.
please check the code and tell if i am missing anything.
o/p i am getting is all 0's.
report ztest5.
tables : ZREPCODMAP.
data: itab type standard table of ZREPCODMAP with header line.
TYPES: BEGIN OF STRUC,
RESULT type RSSH_S_NODEBYNAMEWOL,
ZREPCODMAP-REPDSELM,
END OF STRUC.
DATA: itab1 type standard table of struc with header line.
data: w_hiesel like RSNDI_S_HIESEL.
w_hiesel = '1000KES'.
*data: w_nodebyname type RSNDI_T_NODENM.
data: tab type standard table of RSNDI_S_HTAB with header line.
data: lsubrc type SY-SUBRC.
select * from ZREPCODMAP into table itab where PROFIT_CTR <> ' '.
loop at itab.
concatenate itab-CO_AREA itab-REPDSELM INTO itab1-RESULT.
*write: itab1.
break-point.
CALL FUNCTION 'RSNDI_SHIE_STRUCTURE_GET3'
EXPORTING
I_S_HIEKEY =
i_s_hiesel = w_hiesel
i_s_subtreesel = itab1-result
I_T_NODENAME =
I_NO_NODENM_TABLE = w_flag
IMPORTING
E_S_HIEDIR =
e_subrc = lsubrc
TABLES
E_T_HIEDIRT =
e_t_hierstruc = tab.
E_T_MHIERNODE =
E_T_THIERNODE =
E_T_HIERINTVL =
E_T_NODENAMES = tab.
E_T_NODEATTR =
E_T_LEVEL =
E_T_MESSAGE =
write: tab.
*write: lsubrc.
endloop.
Thanks & Regards,
Vijaya -
Function module to Print Customer Invoice as PDF and to Printer
Hi,
I am writing a program to create a document through FB01. After that I also need to a PRINT the customer invoice for Same document. I need to print Invoice as PDF and Report and print to a Printer. Which Function Modules can I use for these purposes.
Thanks.
FS
Moderator Message: SDN is not here to do your job for you. There are plenty of good developers who work at CSC who can help you out. Thread locked.
Edited by: Neil Gardiner on Oct 5, 2010 6:38 PMHi,
please see the given link,It may help you.
Re: Regarding Print Problem in ALV
Regards,
Shamma
Maybe you are looking for
-
I have found a way to organize photos for a slideshow (windows based)
I had searched for a while for this answer and never came up with exactly what I needed. My problem was that when I synched photos to my iPad (I have a PC), they wouldn't play in the proper order even though I had numbered all the photos. Apparentl
-
Sub conttacting purchase order with Project link
dear all, i have a confusion. when we create normal sub con PO, it works fine. but when i create it w r t project link (account assignment Q & item catagory L) at the time of goods issue against purchase order it show error : no materials available
-
Customer Credit Block at Sales Order Level
Dear Experts, We have requirement, Example: If we received the Bank guarantee from customer(Berry) $10000,till $10000 it should able create the sales order, more than bank guarantee system should block the sales order creation.For same customer(Berry
-
Can I manipulate the TV "safe" area using compressor?
O.K. here's the deal. I'm burning a DVD of footage that's a 720p, converted to SD. I think all the settings are correct for 16 by 9 Widescreen Letterbox, but when I watch the DVD back on the player I notice that some of the image is still being cropp
-
Cmd + p send PDF works with delay?
cmd + p and then Send PDF is one of the best features in Mac, which I use everyday at work. Now it has started to act oddly ; ) It takes about 1 minute before Send PDF opens my Mail. This is pretty annoying problem, which makes my working a bit uneff