How to generate dates sequentially through functions

first let see the sample code
create or replace function FNC_GET_DATE(p_businessdate varchar2) return date
as
v_date date;
begin
v_Date := to_date(p_businessdate,'mm/dd/yyyy') +10;
return v_date;
end;Now i want to run this function in a loop say for N times and the first output of the function must be the input for the second call
Assuming the Initial value of p_businessdate to be 01/01/2012 the output of the function shall be 01/11/2012.
Now the output 01/11/2012 must be sent as input to the function FNC_GET_DATE then the output shall be 01/21/2012.
Now the output 01/21/2012 must be sent as input to the function FNC_GET_DATE then the output shall be 01/31/2012.
Assuming the number of iterations to be 4( here the value of N )output should be something like this:
01/01/2012
01/11/2012
01/21/2012
01/31/2012For this we need a function which has p_busdate and no_of_itereations as input parameter and the retrun type can be a sysrefcursor as shown below once again:
01/01/2012
01/11/2012
01/21/2012
01/31/2012
Please advise.

sri wrote:
first let see the sample code
create or replace function FNC_GET_DATE(p_businessdate varchar2) return date
as
v_date date;
begin
v_Date := to_date(p_businessdate,'mm/dd/yyyy') +10;
return v_date;
end;Now i want to run this function in a loop say for N times and the first output of the function must be the input for the second call
Assuming the Initial value of p_businessdate to be 01/01/2012 the output of the function shall be 01/11/2012.
Now the output 01/11/2012 must be sent as input to the function FNC_GET_DATE then the output shall be 01/21/2012.
Now the output 01/21/2012 must be sent as input to the function FNC_GET_DATE then the output shall be 01/31/2012.
Assuming the number of iterations to be 4( here the value of N )output should be something like this:
01/01/2012
01/11/2012
01/21/2012
01/31/2012For this we need a function which has p_busdate and no_of_itereations as input parameter and the retrun type can be a sysrefcursor as shown below once again:
01/01/2012
01/11/2012
01/21/2012
01/31/2012
Please advise.Would probably be a lot easier to just use a SQL query.
Here i've assumed you already have a date data type to work with.
ME_TUBBZ?variable num_iterations number;
ME_TUBBZ?exec :num_iterations := 2;
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.00
ME_TUBBZ?
ME_TUBBZ?with first_date as
  2  (
  3     select trunc(sysdate) as the_date
  4     from dual
  5  )
  6  select the_date + (level * 10)
  7  from first_date
  8  connect by level <= :num_iterations;
THE_DATE+(LEVEL*10)
08-JUL-2012 00 00:00
18-JUL-2012 00 00:00
2 rows selected.
Elapsed: 00:00:00.00
ME_TUBBZ?
ME_TUBBZ?exec :num_iterations := 4;
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.00
ME_TUBBZ?
ME_TUBBZ?with first_date as
  2  (
  3     select trunc(sysdate) as the_date
  4     from dual
  5  )
  6  select the_date + (level * 10)
  7  from first_date
  8  connect by level <= :num_iterations;
THE_DATE+(LEVEL*10)
08-JUL-2012 00 00:00
18-JUL-2012 00 00:00
28-JUL-2012 00 00:00
07-AUG-2012 00 00:00
4 rows selected.
Elapsed: 00:00:00.00Cheers,

Similar Messages

  • How to extract data by using function module in generic extraction please

    how to extract data by using function module in generic extraction please  give me steps  required

    Dear Deba,
    Generic Extraction via Function Module
    /people/siegfried.szameitat/blog/2005/09/29/generic-extraction-via-function-module
    If the requirement is like extracting data from multiple tables with some complex logic then views cannot be used..so u cna go for FM is used where it can be achieved.
    Chk these
    /people/siegfried.szameitat/blog/2005/09/29/generic-extraction-via-function-module
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a0f46157-e1c4-2910-27aa-e3f4a9c8df33
    check the following thread
    generic extraction with function module
    Generic Extraction with function module
    Regards,
    Ram.

  • Very Urgent : how to generate continious sequential No. (se 38 + smartform)

    Dear All,
                 Could you plz tell me how to generate continious sequential  No.. Atually i have to print TC No. on the form, but it's not available in the SAP. TC No. should be in sequence i.e for first time say it 's 10, at the second time it should be 11, third time it should be 12 and so on.
    Plz tell me ASAP. It's very urgent.
    Looking forward to your earliest response.
    thanks in Advance.
    Gulrez Alam

    You can create a number range(SNRO) to get the continuous numbers.You can use the FM 'NUMBER_GET_NEXT' to get the next number from number range.

  • How to generate data in BPS via function, not having any reference data?

    <b>Hi everybody,
    My approach was to use FM 'API_SEMBPS_SETDATA' but the modified values neighter appear in the layout nor were saved to the infocube after launching 'API_SEMBPS_POST'.</b>
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/2e/260a8563b111d4b2ea0050dadfb23f/content.htm">Application Programming Interface (API)</a>
    <b>What do I have to take into consideration?
    Is there an other way to generate data in BPS?</b>
    Thanks in advance,
    Zeljko
    Here my findings from debugging it:
    In Step 1 FM reads data from planning level/layout correctly:
    Line     ROW     COL     VALUE     INPUT
    1     0001     0001     11     1
    2     0002     0001     0     1
    3     0003     0001     11     1
    4     0004     0001     11     1
    5     0005     0001     11     1
    6     0006     0001     0     1
    (Input = 1 indicates that Input is allowed in this cell)
    In Step 2 FM modifies the values in all lines to 1:
    Line     ROW     COL     VALUE     INPUT
    1     0001     0001     1     1
    2     0002     0001     1     1
    3     0003     0001     1     1
    4     0004     0001     1     1
    5     0005     0001     1     1
    6     0006     0001     1     1
    Finally the modification is imported to FM 'API_SEMBPS_SETDATA'.
    FUNCTION Z_IPS_BPS_GENERATE_DATA_INIT.
    *"*"Local Interface:
      DATA:  area      TYPE upc_y_area             VALUE 'ZIPM0001',
             plevel    LIKE upc_plevel-plevel      VALUE 'ZPOB0091',
             package   LIKE upc_package-ppackage   VALUE '0-ADHOC',
             layout    LIKE upp_param-param        VALUE 'ZPOL0002',
             read_only LIKE upp_ys_flags-read_only VALUE ' '.
      DATA:  res LIKE sy-subrc, res_mess TYPE bapiret2 OCCURS 0.
      DATA:  lt_head   TYPE upc_ys_api_head OCCURS 0,
             lt_col    TYPE upc_ys_api_col  OCCURS 0,
             lt_row    TYPE upc_ys_api_row  OCCURS 0,
             lt_data   TYPE upc_ys_api_data OCCURS 0,
             lt_data2  TYPE upc_ys_api_data OCCURS 0,
             ls_data   like upc_ys_api_data.
    * 1. reading data from planning level/layout
      CALL FUNCTION 'API_SEMBPS_GETDATA'
        EXPORTING
          i_area      = area
          i_plevel    = plevel
          i_package   = package
          i_layout    = layout
          i_read_only = read_only
        IMPORTING
          e_subrc     = res
        TABLES
          etk_head    = lt_head
          etk_row     = lt_row
          etk_col     = lt_col
          etk_data    = lt_data
          etk_return  = res_mess.
      IF sy-subrc <> 0.
        RETURN.
      ENDIF.
    * 2. modify values in lt_data to 1
      LOOP AT lt_data INTO ls_data .
        ls_data-value = '1'.
        APPEND ls_data TO lt_data2.
      ENDLOOP.
    * 3. set dummy values into planning layout/level
      CALL FUNCTION 'API_SEMBPS_SETDATA'
        EXPORTING
          i_area     = area
          i_plevel   = plevel
          i_package  = package
          i_layout   = layout
        IMPORTING
          e_subrc    = res
        TABLES
          itk_row    = lt_row
          itk_data   = lt_data2
          etk_return = res_mess.
      IF sy-subrc <> 0.
        RETURN.
      ENDIF.
    *CALL FUNCTION 'API_SEMBPS_POST'.
    ENDFUNCTION.

    Hi Vlad,
    I tried both alternatives:
    1. Write data in buffer only, not in database
    2. Write data in buffer and then writes from buffer to database
    How can I check or see the data in the buffer? I tried the following: After executing the FM I opened the layout but the numbers are still the same.

  • How to fill data when call function of sap standard script form?

    Hi every experts,
    <Priority Normalized>
    In our system, when we log in 'FR', we can print purchase order in language Franch,in t_code:ME22N.  And when logging in 'EN', we can print it in language English, in ME22N. The English form is just only translated from Franch, with all same structure and frame.  The form is done by script form.
    And when logging in 'ZH', we create a new program, calling function smartform, instead of translating from EN language. Because of different structure and frame, I don't know the way to write script, so  I print puchase order by smartform, when logging in 'ZH'.
    But I have a new issue. Our MM module consultant needs me to print Chinese form if one condition, print English form in other condition.
    So I have no idea to solve it. Because in my program, I get data to fill smartform and call function of smartform. And I don't know how to get data to fill script form. I only know the function name, 'OPEN_FORM' 'WRITE_FORM' 'CLOSE_FORM'.....
    If I only call the several functions, I will get only frame without no data. So who can tell me how to do????
    <Urgency downgraded>
    Edited by: Suhas Saha on Jul 26, 2011 3:34 PM
    Edited by: Vinod Kumar on Jul 26, 2011 4:09 PM

    Hi,
    Normally if we look in NACE transaction, you can see that upto five different FORMS can be assigned to a single output type . i.e. for each form there will be a seperate routine through which it gets called. But it all start from the first form only.
    so you need to write your code in the ENTRY of the first form and if it does not satisfy do not go for processing of it but just exit of that form ENTRY. so that it will take you to next form.
    hope this helps.
    Thanks,
    Venkatesh

  • How to create delta extraction through function module?

    Hi all,
    So far i have created the data source through full load. But currently i would like to convert the couple of function module generic extraction converted through delta.
    Can anyone let me know how to convert from full load to delta using generic extraction
    thanks

    Hi,
    Try these Links, helps u in getting an idea.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/30aefb04-7043-2c10-8e92-941536eebc79?QuickLink=index&overridelayout=true
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/30f1a423-02ae-2e10-bd85-bde64e61fe7b?QuickLink=index&overridelayout=true&51947629650864
    Regards,
    Aravind.

  • How to generate org model through report

    How to generate org model using report .
    please share your information .
    thanks in advance ,
    sapcrm

    Hi,
    It's look like you are assuming that an organizational model can be created from external data input via a report. If so, then your assumption is wrong. There is no standard way to create a org. model from external input.
    As a standard practice SAP provided a report as mentioned in the previous reply. Using this report you can download ECC/R3 org. model into SAP CRM. This is the easy and best proven way of generating org. model in SAP CRM.
    Please let me know, if you need any further clarification
    Do not forget to reward if it helps
    Regards,
    Paul Kondaveeti

  • How to transfer data between planning functions in BPS

    Hi All,
    I have requirement, where user will enter the sales qty plan in manual planning function and need to read the zinfo object to distribute the sales qty accordingly to manufacturing plant and push into infocube.
    To fulfill above requirement, i'm thinking to create one manual plan and user will enter the total sales qty and create one more exit planning function to distribute the sales qty for each plant.
    For above approach, i need to get the data enter in mannual planning function to exit planning function.
    Can anyone let me know how to transfer data from one planning function to other planning function under same planning level and package.
    Thanks you,
    santosh.

    Hi Santosh,
    You can achieve the Distribute functionality using the Standard Planning Function for Distribute (Refer SAP Help for details).
    Moreover you would not have to do anything specifically to transfer data from one Planning Function to another. The application picks up the latest data records for processing whatever Function you are executing. If you want to execute a series of Planning Functions you could use a Planning sequence to achieve the same.
    Hope it helps

  • How to measure data transferred through XI in a day (XI 7.0)

    Is there any transaction or T code which will help me determine data transferred through XI in a day or any period of time?
    Similarly how can I determine  the uptime for XI?

    Hi,
    The amount you see in RWB Performance Monitoring is in bytes, so just divide by 1,000,000 (1024 x 1024 to be exact) to get its MB equivalent or 1,000,000,000 (1024 x 1024 x 1024) for its GB equivalent.
    Hope this helps,
    Edited by: Mark Dihiansan on Jul 31, 2009 8:09 AM

  • How to generate data source for classification data

    Hi all,
    I would like to know how to generate a data source for material classification data .
    Thanks
    OJB

    http://www.mycomputerfiles.com/BW35_SAP/BW_expert_online_docs/Volume_02_2004/Issue_08_September/Understand%20the%20R3%20Classification%20System%20and%20How%20to%20Extract%20.doc
    http://affine.co.uk/cms/uploads/How_to_Extract_Classification_Data_into_BW.pdf
    hope it helps,
    Alex
    Edited by: Alex M on Jan 4, 2011 9:28 AM

  • How to insert Data from a function on server A into a table on Server B.

    Hi,
    I have a function which is like this
    DECLARE @oldmax bigint, @newmax bigint
    SELECT @oldmax = max(exportTimestamp) FROM EXPORT_TIMESTAMPS
    IF @oldmax IS NULL
    SET @oldmax = 0
    SELECT * FROM ServerA.TableA.fnExportTrafficTS(@oldmax) ORDER BY storeID, TrafDate
    SELECT @newmax = max(timestamp) FROM TRAFFIC t
    IF @newmax > @oldmax
    INSERT INTO EXPORT_TIMESTAMPS
    VALUES(@newmax, GETDATE())
    And now i need to insert the data coming out of this function into ServerB Table B
    And the column names and everything coming out of the function is the same columns in Table B.So, no need to worry there.
    I have never worked with inserting data from function through linked server.
    Can someone please help me with this?
    Thanks,
    Sujith

    Well, first of all, your table structure doesn't match the structure of returned table by your table-valued function.
    This is what table valued function returns:
    [storeID] varchar(32) default('noRefID'),
    [TrafDate] [datetime] default(NULL),
    [QtyTraffic] [float] default(0)
    And this is what your table structure is:
    [tUTL_JobLogging_Key] [int] NOT NULL,
    [StoreId] [varchar](10) NULL,
    [TrafDate] [datetime] NULL,
    [Visits] [numeric](8, 2) NULL
    Apart from different size for the StoreID and using float vs. numeric and different name for the last column, there is one extra column in your table.
    So, this is the first problem you need to correct.
    Also, please post how exactly you're calling your procedure? E.g. the procedure has 2 parameters, but the values of them are not used as you're calculating them in the code. So, I assume they should not be parameters for the procedure.
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • How to create material(mm01)  through function module or bapi

    Hi,
        this is kiran iam sap fresher.

    Hi,
    try this
    *& Report ZKAR_MATMAS_BAPI
    *& This program demonstrates how easy it is to create Material master
    *& data using BAPI_MATERIAL_SAVEDATA
    *& The program also generates a report post-execution displaying errors
    *& as well as successful uploads
    REPORT ZKAR_MATMAS_BAPI.
    * TABLES
    * FLAGS *
    DATA: F_STOP. " Flag used to stop processing
    * DATA DECLARATIONS *
    DATA : V_EMPTY TYPE I, " No. of empty records
    V_TOTAL TYPE I. " Total no. of records.
    * STRUCTURES & INTERNAL TABLES
    *BAPI structures
    DATA: BAPI_HEAD LIKE BAPIMATHEAD, " Header Segment with Control Information
    BAPI_MAKT LIKE BAPI_MAKT, " Material Description
    BAPI_MARA1 LIKE BAPI_MARA, " Client Data
    BAPI_MARAX LIKE BAPI_MARAX, " Checkbox Structure for BAPI_MARA
    BAPI_MARC1 LIKE BAPI_MARC, " Plant View
    BAPI_MARCX LIKE BAPI_MARCX, " Checkbox Structure for BAPI_MARC
    BAPI_MBEW1 LIKE BAPI_MBEW, " Accounting View
    BAPI_MBEWX LIKE BAPI_MBEWX, " Checkbox Structure for BAPI_MBEW
    BAPI_RETURN LIKE BAPIRET2. " Return Parameter
    *--- Internal table to hold excel file data
    DATA: IT_INTERN TYPE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
    *--- Internal table to hold Matetrial descriptions
    DATA: BEGIN OF IT_MAKT OCCURS 100.
            INCLUDE STRUCTURE BAPI_MAKT.
    DATA: END OF IT_MAKT.
    *--- Internal to hold the records in the text file
    DATA : BEGIN OF IT_DATA OCCURS 100,
                WERKS(4), " Plant
                MTART(4), " Material type
                MATNR(18), " Material number
                MATKL(9) , " Material group
                MBRSH(1), " Industry sector
                MEINS(3), " Base unit of measure
                GEWEI(3), " Weight Unit
                SPART(2), " Division
                EKGRP(3), " Purchasing group
                VPRSV(1), " Price control indicator
                STPRS(12), " Standard price
                PEINH(3), " Price unit
                SPRAS(2), " Language key
                MAKTX(40), " Material description
                END OF IT_DATA.
    * SELECTION SCREEN. *
    SELECTION-SCREEN BEGIN OF BLOCK SCR1 WITH FRAME TITLE TEXT-111.
    PARAMETER : P_FILE TYPE RLGRAP-FILENAME OBLIGATORY DEFAULT " Input File
    'C:\Material_master.XLS'.
    PARAMETER : P_MAX(4) OBLIGATORY DEFAULT '100'. " no.of recs in a session
    PARAMETERS: P_HEADER TYPE I DEFAULT 0. " Header Lines
    PARAMETERS: P_BEGCOL TYPE I DEFAULT 1 NO-DISPLAY,
    P_BEGROW TYPE I DEFAULT 1 NO-DISPLAY,
    P_ENDCOL TYPE I DEFAULT 100 NO-DISPLAY,
    P_ENDROW TYPE I DEFAULT 32000 NO-DISPLAY.
    SELECTION-SCREEN END OF BLOCK SCR1.
    * AT SELECTION-SCREEN *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
    *--- Validating file
      PERFORM VALIDATE_FILE USING P_FILE.
    * START-OF-SELECTION
    START-OF-SELECTION.
    *--- Perform to convert the Excel data into an internal table
      PERFORM CONVERT_XLS_ITAB.
      IF NOT IT_DATA[] IS INITIAL.
    *--- Perform to delete Header lines
        PERFORM DELETE_HEADER_EMPTY_RECS.
      ENDIF.
    * END OF SELECTION. *
    END-OF-SELECTION.
    *--- Perform to upload Material Master data
      PERFORM UPLOAD_MATMAS.
    * Form : validate_input_file
    * Description : To provide F4 help for file if read from PC
    FORM VALIDATE_FILE USING F_FILE TYPE RLGRAP-FILENAME.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        CHANGING
          FILE_NAME     = F_FILE
        EXCEPTIONS
          MASK_TOO_LONG = 1
          OTHERS        = 2.
      IF SY-SUBRC <> 0.
        MESSAGE S010(ZLKPL_MSGCLASS). " 'Error in getting filename'.
      ENDIF.
    ENDFORM. " validate_input_file
    *& Form CONVER_XLS_ITAB
    * text
    FORM CONVERT_XLS_ITAB.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          FILENAME    = P_FILE
          I_BEGIN_COL = P_BEGCOL
          I_BEGIN_ROW = P_BEGROW
          I_END_COL   = P_ENDCOL
          I_END_ROW   = P_ENDROW
        TABLES
          INTERN      = IT_INTERN.
      IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *--- Perform to move the data into an internal data
      PERFORM MOVE_DATA.
    ENDFORM. " CONVERT_XLS_ITAB
    *& Form MOVE_DATA
    * text
    FORM MOVE_DATA.
      DATA : LV_INDEX TYPE I.
      FIELD-SYMBOLS <FS>.
    *--- Sorting the internal table
      SORT IT_INTERN BY ROW COL.
      CLEAR IT_INTERN.
      LOOP AT IT_INTERN.
        MOVE IT_INTERN-COL TO LV_INDEX.
    *--- Assigning the each record to an internal table row
        ASSIGN COMPONENT LV_INDEX OF STRUCTURE IT_DATA TO <FS>.
    *--- Asigning the field value to a field symbol
        MOVE IT_INTERN-VALUE TO <FS>.
        AT END OF ROW.
          APPEND IT_DATA.
          CLEAR IT_DATA.
        ENDAT.
      ENDLOOP.
    ENDFORM. " MOVE_DATA
    *& Form DELETE_HEADER_EMPTY_RECS
    * To delete the Header and empty records
    FORM DELETE_HEADER_EMPTY_RECS.
      DATA: LV_TABIX LIKE SY-TABIX.
      IF NOT P_HEADER IS INITIAL.
        LOOP AT IT_DATA.
          IF P_HEADER > 0 AND NOT IT_DATA IS INITIAL.
            DELETE IT_DATA FROM 1 TO P_HEADER.
    * P_HEADER = 0.
            EXIT.
          ENDIF.
        ENDLOOP.
      ENDIF.
      CLEAR IT_DATA.
    *--- To delete the empty lines from internal table
      LOOP AT IT_DATA.
        LV_TABIX = SY-TABIX.
        IF IT_DATA IS INITIAL.
          V_EMPTY = V_EMPTY + 1.
          DELETE IT_DATA INDEX LV_TABIX..
        ENDIF.
      ENDLOOP.
      CLEAR IT_DATA.
    *--- Total no of recs in file
      DESCRIBE TABLE IT_DATA LINES V_TOTAL.
      IF V_TOTAL = 0.
        MESSAGE I013(ZLKPL_MSGCLASS). " No records in the file
        F_STOP = 'X'.
        STOP.
      ENDIF.
    ENDFORM. " DELETE_HEADER_EMPTY_RECS
    *& Form UPLOAD_MATMAS
    * to upload Material Master data
    FORM UPLOAD_MATMAS .
      LOOP AT IT_DATA.
    * Header
        UNPACK IT_DATA-MATNR TO IT_DATA-MATNR.
        BAPI_HEAD-MATERIAL = IT_DATA-MATNR.
        BAPI_HEAD-IND_SECTOR = IT_DATA-MBRSH.
        BAPI_HEAD-MATL_TYPE = IT_DATA-MTART.
        BAPI_HEAD-BASIC_VIEW = 'X'.
        BAPI_HEAD-PURCHASE_VIEW = 'X'.
        BAPI_HEAD-ACCOUNT_VIEW = 'X'.
    * Material Description
        REFRESH IT_MAKT.
        IT_MAKT-LANGU = IT_DATA-SPRAS.
        IT_MAKT-MATL_DESC = IT_DATA-MAKTX.
        APPEND IT_MAKT.
    * Client Data - Basic
        BAPI_MARA1-MATL_GROUP = IT_DATA-MATKL.
        BAPI_MARA1-BASE_UOM = IT_DATA-MEINS.
        BAPI_MARA1-UNIT_OF_WT = IT_DATA-GEWEI.
        BAPI_MARA1-DIVISION = IT_DATA-SPART.
        BAPI_MARAX-MATL_GROUP = 'X'.
        BAPI_MARAX-BASE_UOM = 'X'.
        BAPI_MARAX-UNIT_OF_WT = 'X'.
        BAPI_MARAX-DIVISION = 'X'.
    * Plant - Purchasing
        BAPI_MARC1-PLANT = IT_DATA-WERKS.
        BAPI_MARC1-PUR_GROUP = IT_DATA-EKGRP.
        BAPI_MARCX-PLANT = IT_DATA-WERKS.
        BAPI_MARCX-PUR_GROUP = 'X'.
    * Accounting
        BAPI_MBEW1-VAL_AREA = IT_DATA-WERKS.
        BAPI_MBEW1-PRICE_CTRL = IT_DATA-VPRSV.
        BAPI_MBEW1-STD_PRICE = IT_DATA-STPRS.
        BAPI_MBEW1-PRICE_UNIT = IT_DATA-PEINH.
        BAPI_MBEWX-VAL_AREA = IT_DATA-WERKS.
        BAPI_MBEWX-PRICE_CTRL = 'X'.
        BAPI_MBEWX-STD_PRICE = 'X'.
        BAPI_MBEWX-PRICE_UNIT = 'X'.
    *--- BAPI to create material
        CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
        EXPORTING
        HEADDATA = BAPI_HEAD
        CLIENTDATA = BAPI_MARA1
        CLIENTDATAX = BAPI_MARAX
        PLANTDATA = BAPI_MARC1
        PLANTDATAX = BAPI_MARCX
    * FORECASTPARAMETERS =
    * FORECASTPARAMETERSX =
    * PLANNINGDATA =
    * PLANNINGDATAX =
    * STORAGELOCATIONDATA =
    * STORAGELOCATIONDATAX =
    * VALUATIONDATA = BAPI_MBEW1
    * VALUATIONDATAX = BAPI_MBEWX
    * WAREHOUSENUMBERDATA =
    * WAREHOUSENUMBERDATAX =
    * SALESDATA = BAPI_MVKE1
    * SALESDATAX = BAPI_MVKEX
    * STORAGETYPEDATA =
    * STORAGETYPEDATAX =
        IMPORTING
        RETURN = BAPI_RETURN
        TABLES
        MATERIALDESCRIPTION = IT_MAKT
    * UNITSOFMEASURE =
    * UNITSOFMEASUREX =
    * INTERNATIONALARTNOS =
    * MATERIALLONGTEXT =
    * TAXCLASSIFICATIONS =
    * RETURNMESSAGES =
    * PRTDATA =
    * PRTDATAX =
    * EXTENSIONIN =
    * EXTENSIONINX =
        IF BAPI_RETURN-TYPE = 'E'.
          WRITE:/ 'Error:' ,BAPI_RETURN-MESSAGE ,'for material:' ,IT_DATA-MATNR.
        ELSEIF BAPI_RETURN-TYPE = 'S'.
          WRITE: 'Successfully created material' ,IT_DATA-MATNR.
        ENDIF.
      ENDLOOP.
    ENDFORM. " UPLOAD_MATMAS

  • How to retrieve data from a function module and use it in sap script??

    I have a report program, which calls a function module. This function module internally calls an include program. In this program, I have a variable which is to be used in the sap script. How can I send this variable to the sap script

    Hi,
    In your case, Include prog is part of FM, no need to treat it as an Entity.
    Now, Your Answer -
    In SCRIPT - IN Page Window -->
         PERFORM GET_MVAT_TIN IN PROGRAM Z_SCRIPT_PERFORMS_ABAPDB3
         USING &VBDKR-KUNRE&
         CHANGING &STCD1&
         CHANGING &STCD2&
         ENDPERFORM
         IF &STCD1& <> ' '
         <B>MVAT Number :</> &STCD1&
         ENDIF
    Then go to SE38 --> Creat prog with type - Subroutine pool
    In that Write FORM statement for this PERFORM.
    FORM get_mvat_tin TABLES inttab STRUCTURE itcsy
                             outtab STRUCTURE itcsy.
      DATA : v_kunre TYPE kna1-kunnr,
             v_stcd1 TYPE kna1-stcd1,
             v_stcd2 TYPE kna1-stcd2.
      LOOP AT outtab.
        CLEAR outtab-value.
        MODIFY outtab.
      ENDLOOP.
      READ TABLE inttab INDEX 1.
      v_kunre = inttab-value.
      IF v_kunre CA sy-abcde.
      ELSE.
        UNPACK v_kunre TO v_kunre.
      ENDIF.
       " Here You can take your Funcion module ***************************
      SELECT SINGLE stcd1 stcd2 FROM kna1 INTO (v_stcd1, v_stcd2)
                                         WHERE kunnr = v_kunre.
      IF sy-subrc = 0.
        READ TABLE outtab INDEX 1.
        WRITE v_stcd1 TO outtab-value.
        MODIFY outtab INDEX 1.
        READ TABLE outtab INDEX 2.
        WRITE v_stcd2 TO outtab-value.
        MODIFY outtab INDEX 2.
      ENDIF.
    ENDFORM.                                

  • How to generate WPF Xaml through XSD (xml schema definition)

    Hi Experts
    I am working on Projects where we need to generate wpf ui (xaml) at runtime as per different requirements. We are trying to generate xaml from xsd file. We are able to generate UI from xml but as size of xml can be large we are reluctant to use xml as xaml
    generation source. I am attaching a sample image what we are trying to do
    UI elements Description
    For each complex node in xsd, we need a panel which can have add or delete button depending on minoccurs and maxoccurs of the node. Inside panel we want to add different ui elements.
    Please suggest if there is any way to do this or any one have worked in this direction?
    Thanks
    Praveen

    I should think you could use xsl on xsd to generate xaml.
    I have used xsl on xml to do this sort of thing - for reporting style stuff. 
    Xsd is just an odd kind of xml so I should think that's do-able.
    Failing that.
    You could use the template approach and generate xml from that but use c# to read the xsd.
    You would have like a textbox template etc.
    Is that UI truly representative?
    You could leverage the approach I use in this:
    http://social.technet.microsoft.com/wiki/contents/articles/29777.wpf-property-list-editing.aspx
    The EditRow user control has label + editing control as a pair.
    You would add another control for that pattern thing I see in grey after some of those.
    But you could essentially iterate the fields in an xsd , decide what control to use based on field type. 
    Set the label....
    Add that to a Listbox.
    You have a big bunch of xsd and you're thinking of generating the UI?
    I suppose you could then use icustomtypeprovider to generate matching viewmodels inheriting some base vm functionality.
    I don't follow how a "supporting dll" comes into this.
    Could you explain?
    Hope that helps.
    Recent Technet articles:
    Property List Editing ;  
    Dynamic XAML

  • How to read data from a function exit

    Hi friends,
    I have a requirement, where in i am creating a screen exit for ME51N.I am using MEREQ001 enhancement for this.It is working fine, but i am to get data in to this so as to write any code.For that i am using the function exit EXIT_SAPLMEREQ_001 in that same enhancement(thought of doing export and import).
    But the data is declared in this way..
    REFERENCE(IM_REQ_ITEM) TYPE REF TO IF_PURCHASE_REQUISITION_ITEM
    so now it is having a method GET_DATA in which i have all the parameters required.
    can anyone please tell me how to read this data...
    Regards,
    Thoufique.

    thats ok friends..i got the solution.
    Regards,
    Thoufique

Maybe you are looking for