<?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: how to setting table import parameter in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-how-to-setting-table-import-parameter/m-p/6037328#M1350351</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, the problem is here, obviously:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;and ( f~istat = itparm-PSY and g~estat = itparm-PUS )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I guess you're confusing this with SELECT WHERE ... IN ... , which works, for example, with selection options and a blank value is treated like "get all". It's not the case here. I guess the easiest solution would be to have a dynamic WHERE condition, e.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;IF itparm-psy IS not INITIAL.
  concatenate where_condition 'AND F~ISTAT = ITPARM~PSY' into where_condition.
ENDIF.

SELECT ... WHERE (where_condition).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Jelena Perfiljeva on Aug 17, 2009 5:35 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 17 Aug 2009 21:35:28 GMT</pubDate>
    <dc:creator>Jelena_Perfiljeva</dc:creator>
    <dc:date>2009-08-17T21:35:28Z</dc:date>
    <item>
      <title>Function Module: how to setting table import parameter</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-how-to-setting-table-import-parameter/m-p/6037327#M1350350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi, i'm developing a function module. i create a TABLES where it will allow multiple variables  IMPORT from user input to this function module. the tables i set as OPTIONAL and decribed as below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
PSPID	PS_PSPID	CHAR	24
POSID	PS_POSID	CHAR	24
AUFNR	AUFNR	CHAR	12
PSY	J_STATUS	CHAR	5
PUS	J_STATUS	CHAR	5
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in my source code, i done a select statement to process the IMPORT input . the problems i face,for the PSY and PUS  input,  if the one or both &lt;STRONG&gt;input is BLANK, NO RESULT&lt;/STRONG&gt; will display. What i'm try to do , if input one or both  is BLANK, &lt;STRONG&gt;it wil neglect the input and return as ALL RESULT (return result oir all status for input pspis / posid / aufnr)&lt;/STRONG&gt;  . attached the select statement. thank you&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;itparm[] = objparm[].

 select
    a~pspnr a~stspr a~objnr a~pspid
    b~psphi b~objnr as wobjnr b~posid
    c~aufnr c~objnr as nobjnr c~pspel
    d~objnr as jeobjnr d~inact d~stat
    e~objnr as jcobjnr e~udate e~usnam e~utime e~stat as jcstat e~inact as jcinact
    f~istat as syistat
    f~txt04 as sytxt04
    f~spras
    g~estat as usestat
    g~txt04 as ustxt04
    into corresponding fields of table itobj
    from proj as a
    inner join prps as b on a~pspnr = b~psphi
    inner join aufk as c on b~pspnr = c~pspel
    inner join jest as d on c~objnr = d~objnr
    inner join jcds as e on d~objnr = e~objnr
                         and d~stat = e~stat
    inner join tj02t as f on e~stat = f~istat
    inner join tj30t as g on a~stspr = g~stsma
    for all entries in itparm
    where ( a~pspid = itparm-pspid
    or b~posid = itparm-posid 
    or c~aufnr = itparm-aufnr )
   and ( f~istat = itparm-PSY and g~estat = itparm-PUS ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Aug 2009 07:13:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-how-to-setting-table-import-parameter/m-p/6037327#M1350350</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-17T07:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: Function Module: how to setting table import parameter</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-how-to-setting-table-import-parameter/m-p/6037328#M1350351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, the problem is here, obviously:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;and ( f~istat = itparm-PSY and g~estat = itparm-PUS )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I guess you're confusing this with SELECT WHERE ... IN ... , which works, for example, with selection options and a blank value is treated like "get all". It's not the case here. I guess the easiest solution would be to have a dynamic WHERE condition, e.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;IF itparm-psy IS not INITIAL.
  concatenate where_condition 'AND F~ISTAT = ITPARM~PSY' into where_condition.
ENDIF.

SELECT ... WHERE (where_condition).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Jelena Perfiljeva on Aug 17, 2009 5:35 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Aug 2009 21:35:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-how-to-setting-table-import-parameter/m-p/6037328#M1350351</guid>
      <dc:creator>Jelena_Perfiljeva</dc:creator>
      <dc:date>2009-08-17T21:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: Function Module: how to setting table import parameter</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-how-to-setting-table-import-parameter/m-p/6037329#M1350352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You cannot do anything if you are doing a FOR ALL ENTRIES. Your options are to remove those two from yur WHERE clause and delete the records later in a loop that do not satify the conditions for them or loop at your table and do a select for each record(inefficient).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Aug 2009 23:42:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-how-to-setting-table-import-parameter/m-p/6037329#M1350352</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-17T23:42:36Z</dc:date>
    </item>
    <item>
      <title>Re: Function Module: how to setting table import parameter</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-how-to-setting-table-import-parameter/m-p/6037330#M1350353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi, i tried this code and it work!, but i'm not sure is it a good practice. since i can't practiced the ALL ENTERIES i modify the code using lopp statement  this is the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
loop at itparm into waparm.
whercond = '( a~pspid = waparm-pspid or b~posid = waparm-posid or c~aufnr = waparm-aufnr )'.
 if waparm-psy is not initial and waparm-pus is not initial.
  concatenate whercond 'and ( f~istat = waparm-psy and g~estat = waparm-pus )' into whercond separated by space.
 elseif waparm-psy is not initial and waparm-pus is initial.
   concatenate whercond 'and f~istat = waparm-psy' into whercond separated by space.
 elseif waparm-psy is initial and waparm-pus is not initial.
   concatenate whercond 'and g~estat = waparm-pus' into whercond separated by space.
 endif.


 select
    a~pspnr a~stspr a~objnr a~pspid
    b~psphi b~objnr as wobjnr b~posid
    c~aufnr c~objnr as nobjnr c~pspel
    d~objnr as jeobjnr d~inact d~stat
    e~objnr as jcobjnr e~udate e~usnam e~utime e~stat as jcstat e~inact as jcinact
    f~istat as syistat
    f~txt04 as sytxt04
    f~spras
    g~estat as usestat
    g~txt04 as ustxt04
    into corresponding fields of table itobj
    from proj as a
    inner join prps as b on a~pspnr = b~psphi
    inner join aufk as c on b~pspnr = c~pspel
    inner join jest as d on c~objnr = d~objnr
    inner join jcds as e on d~objnr = e~objnr
                         and d~stat = e~stat
    inner join tj02t as f on e~stat = f~istat " system status
    inner join tj30t as g on a~stspr = g~stsma "user status
    where (whercond).

    loop at itobj into waobj.
       move-corresponding waobj to waans.
       append waans to itans.
    endloop.

clear itobj[].
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2009 05:31:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-how-to-setting-table-import-parameter/m-p/6037330#M1350353</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-18T05:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: Function Module: how to setting table import parameter</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-how-to-setting-table-import-parameter/m-p/6037331#M1350354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SELECT in a LOOP is a very bad practice. I thing you can use FOR ALL ENTRIES, but you'll need to review your SELECT statement. Frankly, right now I just can't understand what you're trying to achieve. Perhaps separate SELECT statements would actually work better than this monster.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.S. You don't &lt;STRONG&gt;have&lt;/STRONG&gt; to use aliases, you can use the table names, e.g. proj&lt;SUB&gt;pspnr instead of a&lt;/SUB&gt;pspnr. This makes the code easier to read for yourself and maintain for others.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2009 13:28:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-how-to-setting-table-import-parameter/m-p/6037331#M1350354</guid>
      <dc:creator>Jelena_Perfiljeva</dc:creator>
      <dc:date>2009-08-18T13:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: Function Module: how to setting table import parameter</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-how-to-setting-table-import-parameter/m-p/6037332#M1350355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As I already mentioned, it certainly is not efficient. I also noticed that you are doing a INTO CORRESPONDING FIELDS OF TABLE. This will erase all the previous contents of the internal table, so you introduced another loop (you are already in a loop) to move the contents of this internal table into another internal table (again using MOVE-CORRESPONDING). If you know that the fields of your internal table and the database table match (name and order in which they appear), then it is efficient to use INTO TABLE instead of INTO CORRESPONDING FIELDS OF TABLE. This is correct for the second loop also if you know your second internal table(itans) is of the same structure as the first one(itobj). In fact with internal tables you can also use "APPEND LINES OF itobj TO itans" if you know they are of same structure(sometimes it pays to keep them same).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also look at the APPENDING CORRESPONDING FIELDS OF TABLE for your SELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In short, there is a lot of improvement you can do with your logic.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2009 14:32:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-how-to-setting-table-import-parameter/m-p/6037332#M1350355</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-18T14:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: Function Module: how to setting table import parameter</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-how-to-setting-table-import-parameter/m-p/6037333#M1350356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your quick reply. actually the data will be somehing like this. since i developed a function module, i keep the import parameter in a table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;PSPID	PS_PSPID	CHAR	24
POSID	PS_POSID	CHAR	24
AUFNR	AUFNR	    CHAR	12
PSY  	J_STATUS	CHAR	5
PUS 	J_STATUS	CHAR	5&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the example data will be in OTPARM internal table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
PSPID              POSID          AUFNR     PSY     PUS
aa-aa-aa         a1                                  I001
bb-bb-bb                              b1                        E009
cc-cc-cc
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;                                           &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i'll store  this into an internal table. from the data. it can be seen there a BLANK input. so the blank input should not be included into WHERE connditions. that why in the previous solution, i use SELECT inside LOOP because every line of the IMPORT tables will be generated with different WHERE conditions. i tried to do something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
PSPID         POSID     AUFNR     PSY     PUS        cond_syx
aa-aa-aa     a1                           I001                  if proj~pspid = itparm-pspid and prps~posid = itparm~posid and ....
bb-bb-bb                   b1                         E009     if proj~pspid = itparm-pspid and aufk~aufnr = itparm~paufnr and ....
cc-cc-cc                                                             if proj~pspid = itparm-pspid
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;         &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and implement with FOR ALL ENTERIES, but at the WHERE conditions i failed to put the CONF_SYX. please comment and give opinions. Thanks you very much.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Aug 2009 01:13:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-how-to-setting-table-import-parameter/m-p/6037333#M1350356</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-19T01:13:13Z</dc:date>
    </item>
    <item>
      <title>Re: Function Module: how to setting table import parameter</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-how-to-setting-table-import-parameter/m-p/6037334#M1350357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It just seems that this function module is trying to be too flexible... If you expect the table to have just a few entries, it might actually be more efficient to read all the data for the project number and then eliminate unwanted records in a separate loop. You might want to run some tests to find how the code will perform. Use SQL Trace (ST05) or Runtime Analysis.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Aug 2009 13:33:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-how-to-setting-table-import-parameter/m-p/6037334#M1350357</guid>
      <dc:creator>Jelena_Perfiljeva</dc:creator>
      <dc:date>2009-08-19T13:33:27Z</dc:date>
    </item>
    <item>
      <title>Re: Function Module: how to setting table import parameter</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-how-to-setting-table-import-parameter/m-p/6037335#M1350358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You best solution may be to select entries from the database based on just the PSPID, loop at the result internal table and put your if statements there to delet the records you don't need and keep the records you want.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Aug 2009 17:20:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-how-to-setting-table-import-parameter/m-p/6037335#M1350358</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-19T17:20:38Z</dc:date>
    </item>
  </channel>
</rss>

