<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Function Module error in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-error/m-p/2917132#M686789</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Soniya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;The types and constants specified in a type group have global validity, you cannot use the statement within a FORM or FUNCTION. &amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;So declare your import parameters using standard Data Elements present in SAP like &amp;lt;b&amp;gt;RSREQUNR&amp;lt;/b&amp;gt;  for &amp;lt;b&amp;gt;ROOSOURCER&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;ROOSOURCER&amp;lt;/b&amp;gt; for &amp;lt;b&amp;gt;I_DSOURCE&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;like wise.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this solves your problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amit&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Always reward points for helpful answers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Oct 2007 07:14:53 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-10-16T07:14:53Z</dc:date>
    <item>
      <title>Function Module error</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-error/m-p/2917130#M686787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Friends I created a function module to generate a extractor, but i am getting this error SRSC_S_IF_SIMPLE is UNKNOWN. Kindly let me know what i need to change in Funtion module Function Pool to make it work.&lt;/P&gt;&lt;P&gt;Please tell me your email so I can send the screen shots for the Tabs in MY FM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me with some minor correction in code to make it work.&lt;/P&gt;&lt;P&gt;Extractor Logic is simple: Pick up N fields from KNA1 Customer master and then go to KNB1 to pick up zterm and akont where KUNNR -KNA1 = KUNNR - KNB1 AND KUNNR-ERDAT = KNB1-ERDAT. My custom table ZBW_SFLI001_DS is that will be populated by the code below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My code is as below.&lt;/P&gt;&lt;P&gt;FUNCTION Z_CUSTOMER.&lt;/P&gt;&lt;P&gt;*"----&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;"Local Interface:&lt;/P&gt;&lt;P&gt;*" IMPORTING&lt;/P&gt;&lt;P&gt;*" VALUE(I_REQUNR) TYPE SRSC_S_IF_SIMPLE-REQUNR&lt;/P&gt;&lt;P&gt;*" VALUE(I_DSOURCE) TYPE SRSC_S_IF_SIMPLE-DSOURCE OPTIONAL&lt;/P&gt;&lt;P&gt;*" VALUE(I_MAXSIZE) TYPE SRSC_S_IF_SIMPLE-MAXSIZE OPTIONAL&lt;/P&gt;&lt;P&gt;*" VALUE(I_INITFLAG) TYPE SRSC_S_IF_SIMPLE-INITFLAG OPTIONAL&lt;/P&gt;&lt;P&gt;*" VALUE(I_READ_ONLY) TYPE SRSC_S_IF_SIMPLE-READONLY OPTIONAL&lt;/P&gt;&lt;P&gt;*" VALUE(I_REMOTE_CALL) TYPE ZBW_SFLI001_DS DEFAULT&lt;/P&gt;&lt;P&gt;*" SBIWA_C_FLAG_OFF&lt;/P&gt;&lt;P&gt;*" TABLES&lt;/P&gt;&lt;P&gt;*" I_T_SELECT TYPE SRSC_S_IF_SIMPLE-T_SELECT OPTIONAL&lt;/P&gt;&lt;P&gt;*" I_T_FIELDS TYPE SRSC_S_IF_SIMPLE-T_FIELDS OPTIONAL&lt;/P&gt;&lt;P&gt;*" E_T_DATA STRUCTURE ZBW_SFLI001_DS OPTIONAL&lt;/P&gt;&lt;P&gt;*" EXCEPTIONS&lt;/P&gt;&lt;P&gt;*" NO_MORE_DATA&lt;/P&gt;&lt;P&gt;*" ERROR_PASSED_TO_MESS_HANDLER&lt;/P&gt;&lt;P&gt;*"----&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;*Soniya KAPOOR&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;This code is an example of providing data to a generic extractor&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;based on a function module.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Our generic extractor uses the ZBW_SFLI001_DS table as its extract&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;structure. The ZCALWEEK and ZKUNNR fields will have selections&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;enabled in the generic extractor.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;this structure will be used to decode selections passed from the&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;extractor&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA: l_s_select TYPE SRSC_S_SELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;The following static variables are populated in the first call&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;(the initialization call) to the extractor and then are used in&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;subsequent calls.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;the S_S_IF structure is used to hold incoming parameters.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;STATICS: s_s_if TYPE SRSC_S_IF_SIMPLE,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;a simple counter&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;s_counter_datapakid LIKE SY-TABIX,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;a database cursor that will read and return records&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;s_cursor TYPE CURSOR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Select ranges&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;When the function module is called for the first time the&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;I_T_SELECT table holds any selections from the infopackage.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;We will extract those selections and store them in these&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;ranges. We will then use these ranges to limit the amount&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;of data returned to BW.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;RANGES: l_r_zcalweek FOR ZBW_SFLI001_DS-ZCALWEEK,&lt;/P&gt;&lt;P&gt;l_r_ZKUNNR FOR ZBW_SFLI001_DS-ZKUNNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;The extractor will have a selection for calendar week but the&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;data is stored in the KNA1 table by calendar day. We'll include&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;logic later in the function module to take the incoming calendar&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;week selections and create calendar day selections. We'll put&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;those calendar day selections in this range and then use it&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;to limit the amount of data coming from KNA1.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;RANGES: l_r_ERDAT FOR KNA1-ERDAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Helper variable if we need to loop on week ranges&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA: zweek LIKE ZBW_SFLI001_DS-ZCALWEEK.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Helper internal table to hold KNA1 records that match our&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;selections&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA: ZKNA1 LIKE KNA1 OCCURS 0 WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Helper internal table to hold KNB1 records that match our&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;selections&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA: ZKNB1 LIKE KNB1 OCCURS 0 WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Helper internal table to accumulate data from KNA1&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA: zitab LIKE ZBW_SFLI001_DS OCCURS 0 WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Now we are getting into the real logic of the function module.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;The function module is called several times; once for an&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;initialization and then several more times (once for each data&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;packet) until the function module signals that there is no&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;more data available.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;The I_INITFLAG is an IMPORT parameter that indicates if this&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;is the first call. If so, validate the datasource and put&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;away the other initialization fields into static variables&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;for use in later calls.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF I_INITFLAG = SBIWA_C_FLAG_ON. "Step (A)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;This should never happen, but just in case.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;CASE I_DSOURCE.&lt;/P&gt;&lt;P&gt;WHEN 'ZBW_SFLI001_DS'.&lt;/P&gt;&lt;P&gt;WHEN OTHERS.&lt;/P&gt;&lt;P&gt;IF 1 = 2. MESSAGE E009(R3). ENDIF.&lt;/P&gt;&lt;P&gt;LOG_WRITE 'E' "message type&lt;/P&gt;&lt;P&gt;'R3' "message class&lt;/P&gt;&lt;P&gt;'009' "message number&lt;/P&gt;&lt;P&gt;I_DSOURCE "message variable 1&lt;/P&gt;&lt;P&gt;' '. "message variable 2&lt;/P&gt;&lt;P&gt;RAISE ERROR_PASSED_TO_MESS_HANDLER.&lt;/P&gt;&lt;P&gt;ENDCASE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Make a static copy of the selection field ranges&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;APPEND LINES OF I_T_SELECT TO s_s_if-t_select. "Step (B)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;This grabs a copy of the IMPORT parameters into static variables.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;These static variables can be used in later calls to the function&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;module.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;s_s_if-requnr = I_REQUNR. "Step (B)&lt;/P&gt;&lt;P&gt;s_s_if-dsource = I_DSOURCE. "Step (B)&lt;/P&gt;&lt;P&gt;s_s_if-maxsize = I_MAXSIZE. "Step (B)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;The I_T_FIELDS table holds the fields that the extractor is&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;expecting. You can use this field list to minimize the&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;fields read from database tables.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;APPEND LINES OF I_T_FIELDS TO s_s_if-t_fields. "Step (B)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ELSE. "Initialization mode or data extraction ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;This batch of code is for later calls into the function module&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;(to gather and return data).&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;If we haven't returned any data packets yet (this is the first&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;function module call asking for data packets), then gather up&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;the necessary data.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF s_counter_datapakid = 0. "Step (C)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"Begin of Step (D)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;In the initialization call we copied the incoming I_T_SELECT&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;table (which holds infopackage selections) into the S_S_IF&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;static variable. Now interrogate those selections to create&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;ranges that will be used to restrict the database records read.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;We know (because we defined the extractor) that the only two fields&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;that can have selections are ZCALWEEK and ZKUNNR.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT s_s_if-t_select INTO l_s_select WHERE FIELDNM = 'ZCALWEEK'.&lt;/P&gt;&lt;P&gt;MOVE-CORRESPONDING l_s_select TO l_r_zcalweek.&lt;/P&gt;&lt;P&gt;APPEND l_r_zcalweek.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT s_s_if-t_select INTO l_s_select WHERE FIELDNM = 'ZKUNNR'.&lt;/P&gt;&lt;P&gt;MOVE-CORRESPONDING l_s_select TO l_r_ZKUNNR.&lt;/P&gt;&lt;P&gt;APPEND l_r_ZKUNNR.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;The generic extractor has selections on calendar week, but our data&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;(in the KNA1 table) is captured by flight date. So we need to&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;take our calendar week selections and convert them into flight&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;date selections.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;The ZCALWEEK range could be a single week, it could be a range&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;of weeks, or it could be several of both.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;LOOP AT l_r_zcalweek.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;handle either single values (EQ) or ranges (BT)&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;CASE l_r_zcalweek-option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHEN 'EQ'.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;convert the low value to a date range&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;CALL FUNCTION 'WEEK_GET_FIRST_DAY'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;WEEK = l_r_zcalweek-low&lt;/P&gt;&lt;P&gt;IMPORTING&lt;/P&gt;&lt;P&gt;DATE = l_r_ERDAT-low&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;WEEK_INVALID = 1&lt;/P&gt;&lt;P&gt;OTHERS = 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;l_r_ERDAT-high = l_r_ERDAT-low + 7.&lt;/P&gt;&lt;P&gt;l_r_ERDAT-sign = 'I'.&lt;/P&gt;&lt;P&gt;l_r_ERDAT-option = 'BT'.&lt;/P&gt;&lt;P&gt;APPEND l_r_ERDAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when 'BT'.&lt;/P&gt;&lt;P&gt;zweek = l_r_zcalweek-low.&lt;/P&gt;&lt;P&gt;WHILE zweek &amp;lt;= l_r_zcalweek-high.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;convert the low value to a date range&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;CALL FUNCTION 'WEEK_GET_FIRST_DAY'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;WEEK = zweek&lt;/P&gt;&lt;P&gt;IMPORTING&lt;/P&gt;&lt;P&gt;DATE = l_r_ERDAT-low&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;WEEK_INVALID = 1&lt;/P&gt;&lt;P&gt;OTHERS = 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;l_r_ERDAT-high = l_r_ERDAT-low + 7.&lt;/P&gt;&lt;P&gt;l_r_ERDAT-sign = 'I'.&lt;/P&gt;&lt;P&gt;l_r_ERDAT-option = 'BT'.&lt;/P&gt;&lt;P&gt;APPEND l_r_ERDAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;zweek = zweek + 1.&lt;/P&gt;&lt;P&gt;ENDWHILE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDCASE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;"End of Step (D)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Now it's time to gather the data and populate our ZBW_SFLI001_DS&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;table. But first let's make sure we don't have any residual data&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;already in the table for this same request identifier.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;For example, if we use RSA3 to test the extractor, the request&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;identifier is always TEST. Let's make sure we don't have any&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;left over from previous tests.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DELETE FROM ZBW_SFLI001_DS "Step (E)&lt;/P&gt;&lt;P&gt;WHERE ZREQUNR = s_s_if-requnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Now lets go get data from the KNA1 table that meets our selection&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;criteria.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;SELECT * FROM KNA1 "Step (F)&lt;/P&gt;&lt;P&gt;INTO TABLE ZKNA1&lt;/P&gt;&lt;P&gt;WHERE ERDAT IN l_r_ERDAT&lt;/P&gt;&lt;P&gt;AND KUNNR IN l_r_ZKUNNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Now get all matching KNB1 records (we need these to calculate&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;our expected revenue)&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;SELECT * FROM KNB1 "Step (F)&lt;/P&gt;&lt;P&gt;INTO TABLE ZKNB1&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN ZKNA1&lt;/P&gt;&lt;P&gt;WHERE KUNNR = ZKNA1-KUNNR&lt;/P&gt;&lt;P&gt;AND ERDAT = ZKNA1-ERDAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"Begin of Step (G)&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;now take the KNA1 records and build records to send back to BW&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;LOOP AT ZKNA1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;set the request identZfier&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;zitab-zrequnr = s_s_if-requnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;set the calendar week based on the flight date&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;CALL FUNCTION 'DATE_GET_WEEK'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;DATE = ZKNA1-ERDAT&lt;/P&gt;&lt;P&gt;IMPORTING&lt;/P&gt;&lt;P&gt;WEEK = zitab-zcalweek&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;DATE_INVALID = 1&lt;/P&gt;&lt;P&gt;OTHERS = 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;set class&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;zitab-ZKUNNR = ZKNA1-KUNNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;set total passengers&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;zitab-ZREGIO = ZKNA1-REGIO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;accumulate revenue&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;zitab-ZFAKSD = ZKNA1-FAKSD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;look up the matching KNB1 record to get expected revenue&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;READ TABLE ZKNB1 WITH KEY KUNNR = ZKNA1-KUNNR&lt;/P&gt;&lt;P&gt;ERDAT = zKNA1-ERDAT.&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;zitab-ZZTERM = ZKNB1-ZTERM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;zitab-ZZTERM = 'NULL'.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;set currency key&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;zitab-ZAKONT = ZKNB1-AKONT.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;accumulate baggage weight&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;zitab-ztotbagwt = zKNA1-luggweight.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;set baggage weight unit&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;zitab-zwtunit = zKNA1-wunit.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;this will accumulate key figures that have the same characteristics&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;COLLECT zitab.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;"End of Step (G)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;finally, write the accumulated, summarized records to the database&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;INSERT ZBW_SFLI001_DS FROM TABLE zitab. "Step (H)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;open a database cursor to gather the data from the database&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;table and pass it back to BW. Here the S_S_IF-T_FIELDS&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;internal table (copied from the I_T_FIELDS internal table&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;passed to this function module by BW) is used to make sure we&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;only get the fields that BW actually needs.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;OPEN CURSOR WITH HOLD s_cursor FOR "Step (I)&lt;/P&gt;&lt;P&gt;SELECT (S_S_IF-T_FIELDS) FROM ZBW_SFLI001_DS&lt;/P&gt;&lt;P&gt;WHERE zrequnr = s_s_if-requnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDIF. "First data package ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;This code actually returns a packet of data to BW. It gets the&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;next packet of data from our database table (using the cursor)&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;and puts the data into the E_T_DATA internal table. This&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;internal table is then handed back to BW as a packet of data.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;FETCH NEXT CURSOR s_cursor "Step (J)&lt;/P&gt;&lt;P&gt;APPENDING CORRESPONDING FIELDS&lt;/P&gt;&lt;P&gt;OF TABLE E_T_DATA&lt;/P&gt;&lt;P&gt;PACKAGE SIZE S_S_IF-MAXSIZE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;If there is no more data, close the cursor, remove the data&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;from the ZBW_SFLI001_DS table (since we don't need it anymore)&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;and signal BW that there is no more data.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;IF SY-SUBRC &amp;lt;&amp;gt; 0. "Step (K)&lt;/P&gt;&lt;P&gt;CLOSE CURSOR S_CURSOR. "Step (L)&lt;/P&gt;&lt;P&gt;DELETE FROM zbw_sfli001_ds "Step (M)&lt;/P&gt;&lt;P&gt;WHERE zrequnr = s_s_if-requnr.&lt;/P&gt;&lt;P&gt;RAISE NO_MORE_DATA. "Step (N)&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;accumulate our packet counter&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;s_counter_datapakid = s_counter_datapakid + 1. "Step (O)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Oct 2007 22:46:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-error/m-p/2917130#M686787</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-15T22:46:22Z</dc:date>
    </item>
    <item>
      <title>Re: Function Module error</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-error/m-p/2917131#M686788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Soniya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you tell what is SRSC_S_IF_SIMPLE. As I looked into SE11 but not able to find this. So you may need to define this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Atish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Oct 2007 23:12:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-error/m-p/2917131#M686788</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-15T23:12:57Z</dc:date>
    </item>
    <item>
      <title>Re: Function Module error</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-error/m-p/2917132#M686789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Soniya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;The types and constants specified in a type group have global validity, you cannot use the statement within a FORM or FUNCTION. &amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;So declare your import parameters using standard Data Elements present in SAP like &amp;lt;b&amp;gt;RSREQUNR&amp;lt;/b&amp;gt;  for &amp;lt;b&amp;gt;ROOSOURCER&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;ROOSOURCER&amp;lt;/b&amp;gt; for &amp;lt;b&amp;gt;I_DSOURCE&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;like wise.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this solves your problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amit&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Always reward points for helpful answers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Oct 2007 07:14:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-error/m-p/2917132#M686789</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-16T07:14:53Z</dc:date>
    </item>
    <item>
      <title>Re: Function Module error</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-error/m-p/2917133#M686790</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can u please help me edit my code as i am not able to get what is that you want me to change on the code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;soniya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Oct 2007 20:49:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-error/m-p/2917133#M686790</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-16T20:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: Function Module error</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-error/m-p/2917134#M686791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Soniya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Change the declaration of your import parameters and tables declaration.&lt;/P&gt;&lt;P&gt;Instead of declaring them as &lt;/P&gt;&lt;P&gt;I_REQUNR TYPE SRSC_S_IF_SIMPLE-REQUNR&lt;/P&gt;&lt;P&gt;I_DSOURCE TYPE SRSC_S_IF_SIMPLE-DSOURCE OPTIONAL&lt;/P&gt;&lt;P&gt;I_MAXSIZE TYPE SRSC_S_IF_SIMPLE-MAXSIZE OPTIONAL&lt;/P&gt;&lt;P&gt;I_INITFLAG TYPE SRSC_S_IF_SIMPLE-INITFLAG OPTIONAL&lt;/P&gt;&lt;P&gt;I_READ_ONLY TYPE SRSC_S_IF_SIMPLE-READONLY OPTIONAL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; I_T_SELECT TYPE SRSC_S_IF_SIMPLE-T_SELECT OPTIONAL&lt;/P&gt;&lt;P&gt; I_T_FIELDS TYPE SRSC_S_IF_SIMPLE-T_FIELDS OPTIONAL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use standard data element and structures to declare them as&lt;/P&gt;&lt;P&gt;I_REQUNR TYPE  RSREQUNR&lt;/P&gt;&lt;P&gt;I_DSOURCE TYPE  ROOSOURCER&lt;/P&gt;&lt;P&gt;I_MAXSIZE TYPE RSMAXSIZE&lt;/P&gt;&lt;P&gt;I_INITFLAG TYPE RSINITFLG&lt;/P&gt;&lt;P&gt;I_READ_ONLY TYPE C&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I_T_SELECT LIKE  RSSELECT&lt;/P&gt;&lt;P&gt;I_T_FIELDS LIKE  RSFIELDSEL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This should solve the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amit&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Always reward points for helpful answers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Oct 2007 05:18:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-error/m-p/2917134#M686791</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-17T05:18:58Z</dc:date>
    </item>
  </channel>
</rss>

