Functions which uses condition technique in SD

Hai Guys,
   Do help me out in getting informations about the
   following.
pls tell the functions which uses condition technique in SD
detailed answers or links for this pls...
  Thanku
  Regards
  Jino

Hi Jino,
ntroduction to the Condition Technique Locate the document in its
Use
This section describes the elements within the condition technique. It is organized to reflect the likely sequence of events that you go through when you implement pricing in Customizing. The standard R/3 System includes predefined elements for routine pricing activities. For example, the standard system includes condition types for basic pricing elements, such as material prices, customer and material discounts, and surcharges such as freight and sales taxes. In the case of each element, you can use the standard version, modify the standard version, or create entirely new definitions to suit your own business needs. The sequence of activities is generally as follows:
   1. Define condition types for each of the price elements (prices, discounts, and surcharges) that occur in your daily business transactions.
   2. Define the condition tables that enable you to store and retrieve condition records for each of the different condition types.
   3. Define the access sequences that enable the system to find valid condition records.
   4. Group condition types and establish their sequence in pricing procedures.
For more information about implementing and customizing pricing in sales order processing, see Customizing for Sales and Distribution.
For a more technical description of how the condition technique works, see the Business Workflow documentation for Message Control.
Elements Used in the Condition Technique
Condition Types
Condition Tables
Access Sequences
Pricing procedures
Condition Types Locate the document in its SAP Library structure
Use
A condition type is a representation in the system of some aspect of your daily pricing activities. For example, you can define a different condition type for each kind of price, discount or surcharge that occurs in your business transactions.
Example
Example of a Condition Type
You define the condition type for a special material discount. You specify that the system calculates the discount as an amount (for example, a discount of USD 1 per sales unit). Alternatively, you can specify that the system calculates the discount as a percentage (for example: a 2% discount for orders over 1,000 units). If you want to use both possibilities, you must define two separate condition types. The following figure illustrates how condition types can be used during pricing in a sales document.
This graphic is explained in the accompanying text
In the example in the preceding figure, two discounts apply to the item in the sales order. The first discount is a percentage discount based on the quantity ordered. The second discount is a fixed discount based on the total weight of the item.
Note
You determine the calculation type for a condition type in Customizing. This determines how the system calculates prices, discounts and surcharges for a condition. When setting up condition records, you can enter a different calculation type than the one in Customizing. At present all available calculation types are permitted. The field ‘Calculation type’ can however not be accessed if this field is left empty. After the data release has been printed, if the field has not been completed manually, the proposal is automatically taken from Customizing. After this it is no longer possible to make manual changes.
If you use different calculation types for what are otherwise the same conditions (for example, percentage, as a fixed amount or quantity-dependent), you do not have to define different condition types in Customizing. You can set a different calculation type when maintaining the individual condition records.
Condition Types in the Standard R/3 System
The standard system includes, among many others, the following predefined condition types:
Condition type
Description
PR00
Price
K004
Material discount
K005
Customer-specific material discount
K007
Customer discount
K020
Price group discount
KF00
Freight surcharge (by item)
UTX1
State tax
UTX2
County tax
UTX3
City tax
Creating and Maintaining Condition Types
You can change and maintain condition types provided in the standard version of the SAP R/3 System or you can create new condition types to suit the needs of your own organization. You create and maintain condition types in Customizing.
To reach the condition type screen from the initial Customizing screen for Sales and Distribution:
   1. Basic Functions
      ® Pricing ® Pricing Control ® Define condition types.
      A dialog-box appears, listing the transaction options. Select the corresponding transaction for defining the condition types.
   2. In the Conditions: Condition Types view, you can change existing condition types or create new ones.
Leaving content frame
Condition Tables Locate the document in its SAP Library structure
Use
A condition table defines the combination of fields (the key) that identifies an individual condition record. A condition record is how the system stores the specific condition data that you enter in the system as condition records. For example, when you enter the price for a product or a special discount for a good customer, you create individual condition records.
Example
Example of a Condition Table
A sales department creates condition records for customer-specific material prices. The standard R/3 System includes condition table 005 for this purpose. The key of table 005 includes the following fields:
Sales organization
Distribution channel
Customer
Material
The first two fields identify important organizational data and the last two fields express the relationship between customers and specific materials. When the sales department creates a condition record for a material price or discount that is specific to one customer, the system automatically uses condition table 005 to define the key and store the record.
The following figure illustrates the connection between the condition table and the subsequent condition records.
This graphic is explained in the accompanying text
Condition Tables in the Standard Version
The standard system includes predefined condition tables and specifies them for each access in each predefined access sequence.
Creating or Maintaining Condition Tables
You can change and maintain the condition tables in the standard system. You can also create new condition tables to meet the needs of your own organization. You create and maintain condition tables in Customizing.
From the initial screen of Customizing for Sales and Distribution, you reach the condition table screens by choosing Basic functions ® Pricing ® Pricing Control ® Define condition tables. Then select the mode you want to work with (create, change, display).
Information About Fields
The fields that you choose to make up the key are called the selected fields. The fields from which you can make your selection are called the allowed fields.
Selected Fields
The preceding figure shows the fields that make up the key for condition table 005 (the table for customer/material condition records in Sales). The selected fields show organizational data, such as Sales organization.The fields Customer and Material define the relationship between a particular customer and material.
Field Catalog (Allowed Fields)
When you select fields for the key, you must choose the fields from the list of allowed fields.
Making Changes to Condition Tables
You can make limited changes to existing condition tables. For example, you can change the name of the table or the format of the fast entry screens for the condition records. (Fast entry screens are screens where you can quickly, on a single screen, create and maintain the condition records that refer to the condition table).
Format of a Fast-Entry Screen
The screen consists of header and item lines. Each item line represents a separate condition record. The header lines include the fields that are general to all item lines. When deciding on the format of the fast-entry screen, you can determine whether each field in the key appears as a line in the header or as an item line.
Changing the Format of a Fast-Entry Screen
To change the format of the Fast-Entry screen, choose F6 (Technical View) on the screen where you create or maintain a condition table.
When you determine the format, you have the following possibilities:
If you want the...
Do the following...
Field to appear as a header line
Leave the line field blank
Field to appear as an item
Mark the line field
Text for an item line to appear
Mark the text field
After you make changes to a condition table, choose F16 Generate) to regenerate the table.
Creating a New Condition Table
You can create new condition tables to meet the pricing needs of your organization. When you create a new condition table, you select a combination of fields from the list of allowed fields. The selected fields define the key for the subsequent condition records.
Before you select the fields for the key, there are two things to consider:
The sequence (or hierarchy) of the fields
Which fields you want to appear in the header and item areas of the corresponding fast-entry screens
Important Fields
In sales, the fields you should take into consideration are Sales organization and Distribution channel. The sales organization is nearly always used as a criteria in pricing, because different sales organizations often want to use their own prices, discounts, and surcharges. If you use the sales organization as a criterion in pricing, you should also use the distribution channel. If you do not want to establish different prices, discounts, and surcharges for each distribution channel, use the field anyway. In Customizing for Sales, you can use one distribution channel as a reference for all others (thereby sharing the same pricing data).
Deciding the Sequence of Fields
The order of the fields in a condition table affects the performance of the system during pricing. Two general guidelines will help you create an efficient condition table:
   1. If you select fields that are connected to the structure of your organization (for example, sales organization and distribution channel), assign the fields according to the level of general applicability: Put the most general field, for example, the sales organization in the highest position and the most specific field in the lowest.
   2. After organizational fields, place fields from the document header before those that come from the item level. (For example, Customer comes before Material)
After you have selected the fields for the key on the screen where you maintain and define condition tables, choose F16 Generate to generate the table in the system. Generation prepares the condition table for storing condition data.
Access Sequences Locate the document in its SAP Library structure
Use
An access sequence is a search strategy that the system uses to find valid data for a particular condition type. It determines the sequence in which the system searches for data. The access sequence consists of one or more accesses. The sequence of the accesses establishes which condition records have priority over others. The accesses tell the system where to look first, second, and so on, until it finds a valid condition record. You specify an access sequence for each condition type for which you create condition records.
Note
There are some condition types for which you do not create condition records (header discounts that you can only enter manually, for example). These condition types do not require an access sequence.
ExampleA sales department may offer customers different kinds of prices. The department may create, for example, the following condition records in the system:
A basic price for a material
A special customer-specific price for the same material
A price list for major customers
During sales order processing, a customer may, in theory, qualify for all three prices. The access sequence enables the system to access the data records in a particular sequence until it finds a valid price. In this example, the sales department may want to use the most favourable price for a certain customer. For this reason, it ensures that the system searches for a customer-specific price. The following figure shows how the system searches for the relevant record.
This graphic is explained in the accompanying text
Access Sequences in the Standard R/3 System
The standard R/3 System contains access sequences that are predefined for each of the standard condition types. The names of the access sequences often correspond to the condition types for which they were designed. For example, the access sequence for a material discount (condition type K004) is also called K004.
Creating and Maintaining Access Sequences
You create and maintain access sequences in Customizing. For more information, see the online Implementation Guide for Sales and Distribution.
To reach the access sequence screen, go to the initial screen for Sales and Distribution Customizing and choose:
   1. Basic Functions
      ® Pricing ® Pricing Control ® Define access sequences
Select the transaction that you want to execute (Maintain access).
Leaving content frame
Pricing Procedures Locate the document in its SAP Library structure
Use
The primary job of a pricing procedure is to define a group of condition types in a particular sequence. The pricing procedure also determines:
Which sub-totals appear during pricing
To what extent pricing can be processed manually
Which method the system uses to calculate percentage discounts and surcharges
Which requirements for a particular condition type must be fulfilled before the system takes the condition into account
Example
Example of a Pricing Procedure
If a sales department processes sales orders for a variety of foreign customers, the department can group the customers by country or region. A pricing procedure can then be defined for each group of customers. Each procedure can include condition types that determine, for example, country-specific taxes. In sales order processing, you can specify pricing procedures for specific customers and for sales document types. The system automatically determines which procedure to use.
Pricing Procedures in the R/3 System
The standard system contains pre-defined pricing procedures, which contain frequently used condition types along with their corresponding access sequences. You can, of course, modify these procedures or create your own from scratch.
Creating and Maintaining Pricing Procedures
You create or maintain pricing procedures in Customizing for Sales. For more information on creating pricing procedures, see the online Implementation Guide for Sales and Distribution.
To reach the pricing procedure screen from SD Customizing:
   1. Choose Basic Functions
   2. ® Pricing ® Pricing control ® Define and assign pricing procedures.Select the transaction that you want to execute.
Thanks&Regards,
Phani,
Points If helpful.

Similar Messages

  • How to determine the process alias using condition technique in Transportation & Shipment Scheudling?

    Dear All,
    I am trying to use the functionality Transportation and Shipment Scheduling in GATP.
    I would like to know that how the sytem determines the process alias using condition technique in Transportation & Shipment Scheudling?
    As the Transportation & Shipment Scheduling functionality can be extended further by using the configurable process to overcome the complex scenario. But it needs that process alias should not be determined by using the condition technique.
    Moreover, is it possible to use both functionality simultaneously in the system. i.e. Transportation and Shipment Scheduling using condition technique and Transportation and Shipment Scheduling using configurable process?
    Thanks & Regards
    Piyush Ranpura

    Hi Piyush,
    I have added a small overview in the SCN WIKI which shows you the two ways for the process alias determination and also here as attachment:
    http://wiki.sdn.sap.com/wiki/display/SCM/Time+and+Scheduling+Functions
    Yes, depending on your customizing you can use both scheduling methods in parallel. e.g. you activate CPS just for a specific ITEM category or product and/or customer and/or....what ever you want.
    best regards,
    Michael

  • Help regarding Scheduling date calculation in APO using Condition Technique

    Hi Team,
               The below is the issue I am facing. Could you please help me regarding this?
    For a material MAT1, a stock of 15 is available today i.e. on 15/05/2014 and a Planned Order of 35 is available on 01/08/2014.  I have created a Sales Order of 50 today i.e. 15/05/2014 for this material with a RDD of 20/05/2014. I have maintained the LEAD and the TRAN times as 5 days and 10 days respectively. These are maintained for a particular Route. LOAD, PICK, and UNLD are 0. In the Location master, I haven't defined any Calendar. So, it has to consider all days as working without any holidays.
    For the given RDD of 20/05/2014, system performs the backward scheduling and arrives at a past date of 05/05/2014(20/05/2014-5D-10D) for the MBDAT. Since this date is in the past, the system should set the MBDAT to the current system date i.e. 15/05/2014. Since PICK is 0, the Loading Date also should be 15/05/2014. Since LOAD is 0, the Goods Issue Date also should be 15/05/2014.  Since LEAD and TRAN are 5D and 10D, the Delivery Date should be 15/05/2014+5D+10D=30/05/2014.
    But, in the Sales Order, I am getting a different date. For MBDAT, Loading Date, and Goods Issue date, the dates are 05/07/2014. Transportation Planning Date is 25/06/2014 and Delivery Date is 01.08.2014. During the GATP check, I am getting only a partial confirmation of 15 and the planned order of 35 is not being considered.
    The material is APO relevant and the Scheduling using Condition Technique is being used.
    Kindly help me regarding this and let me know if I am missing anything here.
    Thanks in advance for the help.
    Thanks & Regards,
    Srikanth.

    Hello Srikanth,
    Let us differentiate the problem into two pieces.
    1) Incorrect Scheduling
    2) Future receipts not being considered.
    For the second problem, future reciepts not being considered, which is on 01/08/2014, please check if your system is allowing you to go further and do the confirmation. How long is your Checking Horizon ? Is your checking horizon configured enough to go ahead and pick this reciept element to give the confirmation by creating a second schedule line ?
    For the first problem, LEAD to the best of my knowledge is transportation planning time which means, the MBDAT would be shifted to the extent of the LEAD time to be able to manage the truck though the stock is available today. However, the dates mentioned by you seems to be completely different. Hence, I suggest you to take the ATP check on this line item, go to Delivery proposal screen and click on the graphical representation of the Scheduling results. There you should be able to understand how the calculation is actually happening. Perhaps, there are some calendars that are being used which you'd not be knowing ? May be the condition record has different times maintained in the condition table ? Check the condition table that the system is picking up ? May be you have maintained the route and transportation scheduling in "X" condition table, however system was able to identify a different detailed level table which satisfied the condition and due to which system got the scheduling calculated accordingly ?
    May be it is a good idea to investigate this way. Hope this helps.
    Babu Kilari

  • Transportation time using condition technique!!

    Hi All,
    Can anyone tell how transportation time is calculated using condition technique (APO)?  we have defined following in access sequence for scheduling
    Plant
    Destination country
    Spd trans. zone
    Shipping Conditions
    Weight group
    Factory Calendar ID
    Now if no transportation lane is defined between plant A and ship to party B. Then how system is going to calculate the delivery date? where do we define transportation time between A and B or how it is getting calculated?

    HI,
    You can define a specific transporation duration in the condition technique per chracteristic (e.g. Shipto, plant, etc.).
    Create new condtion records via TA /sapCND/AU11. Create a entry for TRAN and choose a access sequence. There you define a duration e.g. for a ship-to, etc.
    Three options to find a transporation duration:
    1. Directly from the transportation lane  (TA /SAPAPO/SCC_TL1)
    2. Estimated by the system if the transporation lane does not contain any duration (except if the Fix-Duration Indicator was set, note 1464309)
    (The system calculates the transportation time based on the distance between the start and destination location and the average speed of the means of transport used.)
    3. from the contion technique (TA /SAPCND/AU11)
    (A Transportation calendar can be defined just via scheduling userexit 002 for the condition technique.)
    Further details in the SAP Help Docu:
    http://help.sap.com/saphelp_scm50/helpdata/en/3a/92e217b3f54a5eae7a4ac8a99e5e87/content.htm
    Hope it helps.
    regards,
    Michael
    Edited by: Michael Thinschmidt on Aug 31, 2010 3:41 PM

  • Using latest iOs, where can I find the search function which used to be easily accessed?

    On previous versions, this function was easily accessed by scrolling Left  on the main screen.   After you run out of pages of apps, it then used to go into a search screen for the iPhone.

    Touch the center of any Home Screen, and swipe downward.
    Also: http://manuals.info.apple.com/MANUALS/1000/MA1565/en_US/iphone_user_guide.pdf

  • Fetching prices from price list without condition technique

    Hi,
    I have a situation where i need to create a price list of materials which will not be used in my regular sales process pricing.
    I would require these prices to send the data to an external interface.
    As per my understanding the price list is used to get the customer specific prices and will be used in sales processing for automatic pricing. Kindly let me know how to use the price list without using condition technique.
    As i need to create a condition table, Access sequence, condition type to use the price lists, kindly suggest how to avoid the regular process and directly fetch the price of the material from the price list.
    Is this possible, if so do let me know the steps.
    Regards,
    K.Byla

    hi,
    this is to inform you that,
    PRICE LIST:
    it is applicable for a list of Customer's which are under the same group and share same pricing requriments.
    With out using Condiiton Technique we are not able to do anything.
    this is one of the important field which plays a very important role in pricing determination through CONDITION RECORDS.
    you can go through PRICING REPORT, even this does not give any solution to this issue.
    you can go for ENHANCEMENT, by creating a Z table with the fields:
    KSCHL, AMOUNT & OTHER fields into condideration.
    or
    use SM30 and update into the tables - which is not suggested.
    please test and confirm.
    HOPE THIS CLEARS your issue.
    balajia

  • What is a condition technique?

    Hai Guys,
       Do help me out in getting informations about the
       following.
    What is a condition technique?
    detailed answers or links for this pls...
      Thanku
      Regards
      Jino

    Hi,
    A hierarchy of components that define data combinations designed to trigger an action.
    The constellations defined by SAP and the customers are searched for according to a specific hierarchy.
    The condition technique is used, for example, in pricing, account determination and messaging.
    most of the saps functionalites use condition technique to get the value or determiantion of particular functionalities like price of a good , free goods, etc they all use condition technique.
    it is nothing but mainataining of
    1) condition records of a condition type
    2)creating of condition types like PR00,K004,k005 etc
    3)creating and assignning an access sequnce to a condition type
    4)placing the condition types in a procedure
    5)determination or assigning a procedure
    all the above 5 steps constitutes as a condition technique
    Please check this link also.
    Regards,
    Rakesh
    http://www.sapscene.com/sapscene/condition.htm

  • Function module which uses both BAPI's for sales order create and change

    Please name the function module which uses both BAPI's for sales order create and change.
    BAPI_SALESORDER_CREATEFORMDAT2
    BAPI_SALESORDERCHANGE

    Yup.
    you must write a piece of code for this.
    with if else condition.first check if SO is exsist than use second FM to change it else create new SO from first FM.
    logic somethig like this.
    Amit.

  • Function which returns multiple values that can then be used in an SQL Sele

    I'd like to create a function which returns multiple values that can then be used in an SQL Select statement's IN( ) clause
    Currently, the select statement is like (well, this is a very simplified version):
    select application, clientid
    from tbl_apps, tbl_status
    where tbl_apps.statusid = tbl_status.statusid
    and tbl_status.approved > 0;
    I'd like to pull the checking of the tbl_status into a PL/SQL function so my select would look something like :
    select application, clientid
    from tbl_apps
    where tbl_apps.statusid in (myfunction);
    So my function would be running this sql:
    select statusid from tbl_status where approved > 0;
    ... will return values 1, 5, 15, 32 (and more)
    ... but I haven't been able to figure out how to return the results so they can be used in SQL.
    Thanks for any help you can give me!!
    Trisha Gorr

    Perhaps take a look at pipelined functions:
    Single column example:
    SQL> CREATE OR REPLACE TYPE split_tbl IS TABLE OF VARCHAR2(32767);
      2  /
    Type created.
    SQL> CREATE OR REPLACE FUNCTION split (p_list VARCHAR2, p_delim VARCHAR2:=' ') RETURN SPLIT_TBL PIPELINED IS
      2      l_idx    PLS_INTEGER;
      3      l_list   VARCHAR2(32767) := p_list;
      4      l_value  VARCHAR2(32767);
      5    BEGIN
      6      LOOP
      7        l_idx := INSTR(l_list, p_delim);
      8        IF l_idx > 0 THEN
      9          PIPE ROW(SUBSTR(l_list, 1, l_idx-1));
    10          l_list := SUBSTR(l_list, l_idx+LENGTH(p_delim));
    11        ELSE
    12          PIPE ROW(l_list);
    13          EXIT;
    14        END IF;
    15      END LOOP;
    16      RETURN;
    17    END SPLIT;
    18  /
    Function created.
    SQL> SELECT column_value
      2  FROM TABLE(split('FRED,JIM,BOB,TED,MARK',','));
    COLUMN_VALUE
    FRED
    JIM
    BOB
    TED
    MARK
    SQL> create table mytable (val VARCHAR2(20));
    Table created.
    SQL> insert into mytable
      2  select column_value
      3  from TABLE(split('FRED,JIM,BOB,TED,MARK',','));
    5 rows created.
    SQL> select * from mytable;
    VAL
    FRED
    JIM
    BOB
    TED
    MARK
    SQL>Multiple column example:
    SQL> CREATE OR REPLACE TYPE myrec AS OBJECT
      2  ( col1   VARCHAR2(10),
      3    col2   VARCHAR2(10)
      4  )
      5  /
    Type created.
    SQL>
    SQL> CREATE OR REPLACE TYPE myrectable AS TABLE OF myrec
      2  /
    Type created.
    SQL>
    SQL> CREATE OR REPLACE FUNCTION pipedata(p_str IN VARCHAR2) RETURN myrectable PIPELINED IS
      2    v_str VARCHAR2(4000) := REPLACE(REPLACE(p_str, '('),')');
      3    v_obj myrec := myrec(NULL,NULL);
      4  BEGIN
      5    LOOP
      6      EXIT WHEN v_str IS NULL;
      7      v_obj.col1 := SUBSTR(v_str,1,INSTR(v_str,',')-1);
      8      v_str := SUBSTR(v_str,INSTR(v_str,',')+1);
      9      IF INSTR(v_str,',')>0 THEN
    10        v_obj.col2 := SUBSTR(v_str,1,INSTR(v_str,',')-1);
    11        v_str := SUBSTR(v_str,INSTR(v_str,',')+1);
    12      ELSE
    13        v_obj.col2 := v_str;
    14        v_str := NULL;
    15      END IF;
    16      PIPE ROW (v_obj);
    17    END LOOP;
    18    RETURN;
    19  END;
    20  /
    Function created.
    SQL>
    SQL> create table mytab (col1 varchar2(10), col2 varchar2(10));
    Table created.
    SQL>
    SQL> insert into mytab (col1, col2) select col1, col2 from table(pipedata('(1,2),(2,3),(4,5)'));
    3 rows created.
    SQL>
    SQL> select * from mytab;
    COL1       COL2
    1          2
    2          3
    4          5

  • How to call oracle Function which has If else condition in Data Template

    Hi,
    currently I am working on creating Data Template which uses a Oracle Function which I need to make use in my data template. But I have some confusions on using the same. Could anybody please help me in this regard.
    I have a function like this,
    function invoice_query (p_facility_id facility.facility_id%TYPE,
    p_wave_nbr pick_directive.wave_nbr%TYPE,
    p_container_id unit_pick_group_detail.container_id%TYPE,
    p_distro_nbr unit_pick_group_detail.distro_nbr%TYPE) return invoice_refcur IS
    refcur invoice_refcur;
    begin
    IF p_wave_nbr IS NOT NULL THEN
    OPEN refcur FOR SELECT t1.distro_nbr,
    t1.cust_order_nbr,
    t1.pick_not_before_date,
    SYSDATE,
    t1.ship_address_description,
    t1.ship_address1,
    t1.ship_address2,
    t1.ship_address3,
    t1.ship_address4,
    t1.ship_address5,
    t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip,
    t1.ship_country_code,
    t1.bill_address_description,
    t1.bill_address1,
    t1.bill_address2,
    t1.bill_address3,
    t1.bill_address4,
    t1.bill_address5,
    t1.bill_city || ', ' || t1.bill_state || ' ' || t1.bill_zip,
    t1.bill_country_code,
    min(t2.pick_order),
    NULL,
    t2.wave_nbr
    FROM stock_order t1,
    pick_directive t2,
    unit_pick_group_detail t3
    WHERE t1.facility_id = t2.facility_id
    AND t1.facility_id = t3.facility_id
    AND t2.facility_id = t3.facility_id
    AND t1.distro_nbr = t2.distro_nbr
    AND t1.distro_nbr = t3.distro_nbr
    AND t2.distro_nbr = t3.distro_nbr
    AND t1.facility_id = p_facility_id
    AND t2.wave_nbr = p_wave_nbr
    AND g_scp(p_facility_id, 'interface_tcp_flag') = 'N'
    AND t2.pick_type = 'U'
    AND t3.group_id in (SELECT t4.group_id
    FROM unit_pick_group t4
    WHERE t4.facility_id = p_facility_id
    AND t4.wave_nbr = p_wave_nbr)
    GROUP BY t1.distro_nbr,
    t1.cust_order_nbr,
    t1.pick_not_before_date,
    t1.ship_address_description,
    t1.ship_address1,
    t1.ship_address2,
    t1.ship_address3,
    t1.ship_address4,
    t1.ship_address5,
    t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip,
    t1.ship_country_code,
    t1.bill_address_description,
    t1.bill_address1,
    t1.bill_address2,
    t1.bill_address3,
    t1.bill_address4,
    t1.bill_address5,
    t1.bill_city || ', ' || t1.bill_state || ' ' || t1.bill_zip,
    t1.bill_country_code,
    t2.wave_nbr
    ORDER BY MIN(t3.group_id), MAX(t3.slot);
    elsif p_container_id is not null then
    OPEN refcur FOR SELECT distinct t1.distro_nbr,
    t1.cust_order_nbr,
    t1.pick_not_before_date,
    SYSDATE,
    t1.ship_address_description,
    t1.ship_address1,
    t1.ship_address2,
    t1.ship_address3,
    t1.ship_address4,
    t1.ship_address5,
    t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip,
    t1.ship_country_code,
    t1.bill_address_description,
    t1.bill_address1,
    t1.bill_address2,
    t1.bill_address3,
    t1.bill_address4,
    t1.bill_address5,
    t1.bill_city || ', ' || t1.bill_state || ' ' || t1.bill_zip,
    t1.bill_country_code,
    NULL,
    t2.dest_id,
    null
    FROM stock_order t1,
    unit_pick_group_detail t2
    WHERE t1.facility_id = t2.facility_id
    and t1.distro_nbr = t2.distro_nbr
    and t1.facility_id = p_facility_id
    AND g_scp(p_facility_id, 'interface_tcp_flag') = 'N'
    AND t2.container_id = p_container_id;
    else
    open refcur for SELECT distinct t1.distro_nbr,
    t1.cust_order_nbr,
    t1.pick_not_before_date,
    SYSDATE,
    t1.ship_address_description,
    t1.ship_address1,
    t1.ship_address2,
    t1.ship_address3,
    t1.ship_address4,
    t1.ship_address5,
    t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip,
    t1.ship_country_code,
    t1.bill_address_description,
    t1.bill_address1,
    t1.bill_address2,
    t1.bill_address3,
    t1.bill_address4,
    t1.bill_address5,
    t1.bill_city || ', ' || t1.bill_state || ' ' || t1.bill_zip,
    t1.bill_country_code,
    NULL,
    NULL,
    t3.wave_nbr
    FROM stock_order t1,
    unit_pick_group_detail t2,
    unit_pick_group t3
    WHERE t1.facility_id = t2.facility_id
    and t2.facility_id = t3.facility_id
    and t1.distro_nbr = t2.distro_nbr
    and t2.group_id = t3.group_id
    and t1.facility_id = p_facility_id
    AND g_scp(p_facility_id, 'interface_tcp_flag') = 'N'
    AND t2.distro_nbr = p_distro_nbr;
    END IF;
    return refcur;
    end;
    I have created data template like following,
    <sqlStatement name="Q_INVOICE">
                   <![CDATA[
              SELECT Pack_Slip_R.invoice_query(:P_FACILITY_ID,:P_WAVE_NBR,:P_CONTAINER_ID,:P_DISTRO_NBR) from dual
                                                     ]]>
    </sqlStatement>
    But how does I create a element for the "t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip" column in the oracle function. I normally create an element like following,
    <group name="G_INVOICE" source="Q_INVOICE">
                   <element name="CUST_ORDER_NBR" value="cust_order_nbr"/>
                   <element name=":dest_id" value="dest_id"/>
    </Group>
    But how do i create element if a column name is kind of dynamic. Please help. I cannot Rename/change the Column in SQL Query. Please let me know If I could handle this whole logic in BI Publsiher.
    Regards,
    Ashoka BL

    try useing alias
    t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip as <COLUMN_ALIAS>

  • Which function is used for  adding days to given month

    which function is used for  adding days to given month

    Hi Jagrut,
    Good ... Check out the following examples
    <b>Get a date</b>
    DATE_GET_WEEK Returns week for a date
    WEEK_GET_FIRST_DAY Returns first day for a week
    RP_LAST_DAY_OF_MONTHS Returns last day of month
    FIRST_DAY_IN_PERIOD_GET Get first day of a period
    LAST_DAY_IN_PERIOD_GET Get last day of a period
    RP_LAST_DAY_OF_MONTHS Determine last day of month
    <b>Date calculations</b>
    DATE_COMPUTE_DAY Returns a number indicating what day of the week the date falls on. Monday is returned as a 1, Tuesday as 2, etc.
    DATE_IN_FUTURE Calculate a date N days in the future.
    RP_CALC_DATE_IN_INTERVAL Add days/months to a date
    RP_CALC_DATE_IN_INTERVAL Add/subtract years/months/days from a date
    SD_DATETIME_DIFFERENCE Give the difference in Days and Time for 2 dates
    MONTH_PLUS_DETERMINE Add or subtract months from a date. To subtract a month, enter a negative value for the 'months' parameter.
    DATE_CREATE Calculates a date from the input parameters:
    Example: DATE_CREATE
    CALL FUNCTION 'DATE_CREATE'
    EXPORTING
       anzahl_jahre  = 1
       anzahl_monate = 2
       anzahl_tage   = 3
       datum_ein     = '20010101'
    IMPORTING
       datum_aus     = l_new_date.
       Result:
       l_new_date = 20020304
    Example: MONTH_PLUS_DETERMINE
    data: new_date type d.
    CALL FUNCTION 'MONTH_PLUS_DETERMINE'
    EXPORTING
    months = -5 " Negative to subtract from old date, positive to add
    olddate = sy-datum
    IMPORTING
    NEWDATE = new_date.
    write: / new_date.
    <b>Hollidays</b>
    HOLIDAY_GET Provides a table of all the holidays based upon a Factory Calendar &/ Holiday Calendar.
    HOLIDAY_CHECK_AND_GET_INFO Useful for determining whether or not a date is a holiday. Give the function a date, and a holiday calendar, and you can determine if the
    date is a holiday by checking the parameter HOLIDAY_FOUND.
    Example: HOLIDAY_CHECK_AND_GET_INFO
    data: ld_date                 like scal-datum  default sy-datum,
          lc_holiday_cal_id       like scal-hcalid default 'CA',
          ltab_holiday_attributes like thol occurs 0 with header line,
          lc_holiday_found        like scal-indicator.
    CALL FUNCTION 'HOLIDAY_CHECK_AND_GET_INFO'
      EXPORTING
        date                               = ld_date
        holiday_calendar_id                = lc_holiday_cal_id
        WITH_HOLIDAY_ATTRIBUTES            = 'X'
      IMPORTING
        HOLIDAY_FOUND                      = lc_holiday_found
      tables
        holiday_attributes                 = ltab_holiday_attributes
      EXCEPTIONS
        CALENDAR_BUFFER_NOT_LOADABLE       = 1
        DATE_AFTER_RANGE                   = 2
        DATE_BEFORE_RANGE                  = 3
        DATE_INVALID                       = 4
        HOLIDAY_CALENDAR_ID_MISSING        = 5
        HOLIDAY_CALENDAR_NOT_FOUND         = 6
        OTHERS                             = 7.
    if sy-subrc = 0 and
       lc_holiday_found = 'X'.
      write: / ld_date, 'is a holiday'.
    else.
      write: / ld_date, 'is not a holiday, or there was an error calling the function'.
    endif.
    Checking dates
    DATE_CHECK_PLAUSIBILITY Check to see if a date is in a valid format for SAP. Works well when validating dates being passed in from other systems.
    Converting dates
    DATE_CONV_EXT_TO_INT Conversion of dates to SAP internal format e.g. '28.03.2000' -> 20000328 Can also be used to check if a date is valid ( sy-subrc <> 0 )
    Function to return literal for month
    he table you want to use is T247. You can also use the function MONTH_NAMES_GET.
    You can also try table T015M. It has the month number in it's key.
    Formatting
    DATUMSAUFBEREITUNG Format date as the user settings
    Other
    MONTH_NAMES_GET It returns all the month and names in repective language.
    Good Luck and thanks
    AK

  • Which SQL function to use to get previous month's data?

    Hi
    The reporting need: Display of two month's payroll run results....current and previous (based on the parameter passed) in Oracle Discoverer.
    Data source: A table in which run result values are stored. Of course to be linked to number of other tables.
    Can somebody guide me on which SQL function to use to get the data for previous month?
    Secondly, as Discoverer does not support parameters, I cannot put parameter in the query itself. I'll be applying parameter later while generating my report.
    Please advice.
    Thanks and regards,
    Aparna

    It's not very clear in my head... but you can try :
    SQL> select * from test;
    ENAM        SAL DT
    TOTO       1000 30/05/06
    TOTO       1001 20/04/06
    TOTO       1002 11/03/06
    TATA       2000 30/05/06
    TATA       1500 20/04/06
    TUTU       3500 30/05/06
    6 rows selected.
    SQL> select ename, dt, sal currmonth,
                case when trunc(lag(dt,1,dt) over (partition by ename order by dt),'MM') = trunc(add_months(dt,-1),'MM')
                     then lag(sal,1,sal) over (partition by ename order by dt)
                     else null end prevmonth
         from   test
    SQL> /
    ENAM DT        CURRMONTH  PREVMONTH
    TATA 20/04/06       1500
    TATA 30/05/06       2000       1500
    TOTO 11/03/06       1002
    TOTO 20/04/06       1001       1002
    TOTO 30/05/06       1000       1001
    TUTU 30/05/06       3500
    6 rows selected.
    SQL>
    SQL> Nicolas.
    Just an additional question : do the previous month is current month-1, or is there hole in month suite (e.g. the previous month can be current month-2) ?
    Message was edited by:
    N. Gasparotto

  • Which are function modules used to convert into XML format in SAP 4.6c Ver

    which are function modules used to convert into XML format in SAP 4.6c Ver

    Hi,
    check this program , I think this will help you
    TYPE-POOLS: ixml.
    TYPES: BEGIN OF xml_line,
    data(256) TYPE x,
    END OF xml_line.
    data : itab like catsdb occurs 100 with header line.
    data : file_location type STRING.
    data : file_name like sy-datum.
    data : file_create type STRING.
    file_name = sy-datum .
    file_location = 'C:\xml\'.
    concatenate file_location file_name into file_create.
    concatenate file_create '.XML' into file_create.
    DATA: l_xml_table TYPE TABLE OF xml_line,
    l_xml_size TYPE i,
    l_rc TYPE i.
    select * from catsdb into table itab.
    append itab .
    CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'
    EXPORTING
    I_FIELD_SEPERATOR =
    I_LINE_HEADER =
    I_FILENAME =
    I_APPL_KEEP = ' '
    I_XML_DOC_NAME =
    IMPORTING
    PE_BIN_FILESIZE = l_xml_size
    TABLES
    i_tab_sap_data = itab
    CHANGING
    I_TAB_CONVERTED_DATA = l_xml_table
    EXCEPTIONS
    CONVERSION_FAILED = 1
    OTHERS = 24
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL METHOD cl_gui_frontend_services=>gui_download
    EXPORTING
    bin_filesize = l_xml_size
    filename = file_create
    filetype = 'BIN'
    CHANGING
    data_tab = l_xml_table
    EXCEPTIONS
    OTHERS = 24.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    write : 'INTERNAL TABLE DATA IS SUCCESSFULLY DOWNLOADED TO LOCATION', file_create .
    Thanks.

  • Use function which returns clob in proceudre

    Hello,
    I need some help with a function call i am using.
    I have a SYSMAN function which i like to call in procedure.
    The output from the function is a CLOB.
    Executing the statement in SqlPlus returns 2 lines of data, but written into a procedure returns in an error.
    The procedure looks like this:
         CREATE OR REPLACE PROCEDURE large_val as
         cSql_text          CLOB;
         sSql_stmt           varchar2(200);
         job_id          varchar2(80);
         exec_id          varchar2(80);
         parm          varchar2(50);
         begin
         job_id := '82A11DD897876D29E0400A0A8A1051A7';
         exec_id := '0000000000000000';
         parm := 'large_sql_script';
         sSql_stmt := 'SELECT SYSMAN.MGMT_JOBS.get_large_param(' || ''''||job_id||'''' ||',' ||''''||exec_id||''''||','||''''||parm|| '''' || ') FROM DUAL;';
         dbms_output.put_line(sSql_stmt);
         execute immediate sSql_stmt into cSql_text;
         END large_val;
    The output from dbms_output i am able to run a statement in SqlPlus without error:
         SELECT SYSMAN.MGMT_JOBS.get_large_param('82A11DD897876D29E0400A0A8A1051A7','0000000000000000','large_sql_script') FROM DUAL ;
    and it returns 2 lines.
    Running it as a procecure show's an error i don't understand.
    exec large_val;
    BEGIN large_val; END;
    ERROR at line 1:
    ORA-00911: invalid character
    ORA-06512: at "SCHEMTS.LARGE_VAL", line 23
    ORA-06512: at line 1
    Hope anyone can help me.
    Any help is appreciated.
    Regards,
    Ben

    Kiran wrote:
    you cannot use CLob with select query.Yes you can. At least since 10gR1, but possibly in earlier versions too.
    @OP:
    Why aren't you using bind variables? And why are you using dynamic sql at all?
    You could just do
      cSql_text := SYSMAN.MGMT_JOBS.get_large_param(job_id, exec_id, parm);

  • Plsql use a function which returns a ref cursor

    Hi
    I've been using an function which returns a ref cursor. I've been returning this into a java resultset. Fine!
    Now i'm in plsql and want to use the same function. I'm not sure how to get this resultset in plsql.

    It's not very practical to use a refcursor like you want to, but here you go
    create or replace function test_ref
    return sys_refcursor
    is
    v_rc sys_refcursor;
    begin
    open v_rc for select emp_name  from emp ;
    return v_rc;
    end;
    declare
    v_rc sys_refcursor;
    v_emp_name emp.emp_name%type;
    begin
    v_rc :=  test_ref ;
    loop
        fetch v_rc into v_emp_name ;
        exit when v_rc%notfound ;
        dbms_output.put_line('Employee Name: '||v_emp_name );
    end loop;
    end;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for