Assign values to bapi structure dynamically

Hi,
I have to use the BAPI, BAPI_MATERIAL_SAVEDATA to extend the material to different plant specific views. I have to use the structure BAPI_MARC and other structures in order to do this. But the values to be passed to the structure BAPI_MARC are not fixed. These values will be maintained in a custom table against the structure name and field name for a particular plant.
In the program I have to extract the structure name and field name for a corresponding plant from custom table and fill the corresponding value in BAPI structure BAPI_MARC.
Now, internal table in the program is having these details.
How can I fill the bapi structure BAPI_MARC based on this information.
For example, if in custom table, value 0001 is maintained against the field PUR_GROUP, I have to fill the field PUR_GROUP in strcutre BAPI_MARC with 0001.
Hope I am clear in explaining the problem. Please let me know how to aciheve this?
Best Regards,
Kumar.

Hi,
I have tried to implement that in a sample program first. Please have a look at the code below.
DATA: BEGIN OF line,
        col1 TYPE i,
        col2 TYPE i,
        col3 TYPE i,
      END OF line.
DATA comp(4) TYPE c VALUE 'COL3'.
FIELD-SYMBOLS: <f1> TYPE ANY, <f3> TYPE ANY.
ASSIGN line TO <f1>.
ASSIGN COMPONENT comp OF STRUCTURE <f1> TO <f3>.
IF <f3> IS ASSIGNED.
ENDIF.
I checked in the debugging mode and the value of <f3> in debugging mode is 0, but not line-col3.
Best Regards,
Kumar

Similar Messages

  • Assigning value to a range dynamically

    Hello All,
    I want to assign the values to a range dynamically.
    For example in the following piece of code, I cannot directly assign wa-kunnr to
    r_kunnr-low.
    LOOP AT ITAB INTO WA.
    r_kunnr-sign    = 'I'.
    r_kunnr-option = 'EQ'.
    r_kunnr-low     = wa-kunnr.
    APPEND r_kunnr.
    ENDLOOP.
    Can this be done dynamically? If I use following code I am getting a short dump.
    lv_fnam = 'wa-kunnr'.
    LOOP AT ITAB INTO WA.
    r_kunnr-sign    = 'I'.
    r_kunnr-option = 'EQ'.
    r_kunnr-low     = ( lv_fnam ).
    APPEND r_kunnr.
    ENDLOOP.
    Could anyone please suggest how to do this?
    Regards
    Indrajit

    Hi,
    Try giving it capital letters
    lv_fnam = <b>'WA-KUNNR'</b>.
    LOOP AT ITAB INTO WA.
    r_kunnr-sign = 'I'.
    r_kunnr-option = 'EQ'.
    r_kunnr-low = ( lv_fnam ).
    APPEND r_kunnr.
    ENDLOOP.
    Thanks
    Naren

  • Assigning values to a range dynamically

    Hello All,
    I want to assign the values to a range dynamically.
    For example in the following piece of code, I cannot directly assign wa-kunnr to
    r_kunnr-low.
    LOOP AT ITAB INTO WA.
    r_kunnr-sign = 'I'.
    r_kunnr-option = 'EQ'.
    r_kunnr-low = wa-kunnr.
    APPEND r_kunnr.
    ENDLOOP.
    Can this be done dynamically? If I use following code I am getting a short dump.
    lv_fnam = 'wa-kunnr'.
    LOOP AT ITAB INTO WA.
    r_kunnr-sign = 'I'.
    r_kunnr-option = 'EQ'.
    r_kunnr-low = ( lv_fnam ).
    APPEND r_kunnr.
    ENDLOOP.
    Could anyone please suggest how to do this?
    Regards
    Indrajit

    Hi Indrajit,
    this is working perfectly for me ...i did not get any error
    REPORT  ychatest.
    TABLES : kna1.
    DATA : wa TYPE kna1,
           lv_fnam(10).
    FIELD-SYMBOLS : <fs> TYPE ANY.
    SELECT-OPTIONS : s_kunnr FOR kna1-kunnr.
    INITIALIZATION.
      wa-kunnr = '100'.
      lv_fnam = 'WA-KUNNR'.
      ASSIGN (lv_fnam) TO <fs>.
      s_kunnr-sign = 'I'.
      s_kunnr-option = 'BT'.
      s_kunnr-low = <fs>.
      APPEND s_kunnr.

  • ASSIGN VALUE TO XML ATTRIBUTE DYNAMICALLY

    how can we create and asign value to an XML attribute dynamically?

    Hi Harshit,
    In this case you should use append xml instead of assign in the assignment action block.
    Assigfn values to local variables from sql query say "Local.Shift", "Local.Quantity" and "Local.Total" then append it to your output as:
    <root  Shift="#Local.Shift#" Qty="#Local.Quantity#" Total="#Local.Total#" />
    Append it to parent of <root /> element.
    Regards,
    Swaroop

  • BCD_FIELD_OVERFLOW  error while assigning value to dynamic work area

    Hi guys,
                I am trying following code --it uses dynamic table concept.
           LABSTD2 TYPE P DECIMALS  1,
           LABST_2 TYPE P DECIMALS   1,
           LABST_12 TYPE P DECIMALS 1,
           T_ARTMAS-LABST_12 = T_ARTMAS-LABSTD1 + T_ARTMAS-LABSTD2.
           ASSIGN COMPONENT 'LABST_12' OF STRUCTURE <DYN_WA> TO <DYN_FIELD>.
           <DYN_FIELD> = T_ARTMAS-LABST_12.
    Value in T_ARTMAS-LABST_12 in debug was 14690.0....still it gave following error-----
    Runtime Error       BCD_FIELD_OVERFLOW
    Except.                CX_SY_CONVERSION_OVERFLOW
    Even i changed decleartion as follows
    LABST_12 TYPE P lenght 10 DECIMALS 1,
    Still it is giving same problem ...
    Kindly help.

    Hi, I think it has nothing to do with an overflow but something with the code. Try this simple (rather stupied) code:
    TYPES: BEGIN OF ty_line,
            fld1      TYPE p DECIMALS 1,
            fld2      TYPE p DECIMALS 1,
            fld3      TYPE p DECIMALS 1,
          END OF ty_line.
    DATA lv_rec       TYPE ty_line.
    DATA lv_count(1)  TYPE n.
    DATA lv_fld1      TYPE p DECIMALS 1.
    DATA lv_fld2      TYPE p DECIMALS 1.
    DATA lv_fld3      TYPE p DECIMALS 1.
    DATA lv_field     TYPE string.
    FIELD-SYMBOLS: <fs_fld> TYPE any.
    BREAK-POINT.
    lv_fld1 = 15211444 / 10.
    lv_fld2 = 54879072 / 10.
    lv_fld3 = lv_fld1 + lv_fld2.
    DO 3 TIMES.
      lv_count = lv_count + 1.
      CLEAR lv_field.
      CONCATENATE 'lv_rec-fld' lv_count INTO lv_field.
      CONDENSE lv_field NO-GAPS.
      ASSIGN (lv_field) TO <fs_fld>.
      <fs_fld> = lv_fld3.
    ENDDO.
    BREAK-POINT.
    Succes.

  • Assigning part of a string dynamically to a component of a structure

    Hello,
    I want to take part of a string
    example: value = string+10(7)
    and assign this value to a structure. But I only have the fieldnames of the structure. I need something like the following
    Assign value TO COMPONENT (fieldname) of structure
    Thanks.
    Regards, Lars.

    do you have a set structure name you're dealing with or is that dynamic?
    If it's the first scenario and, say, you were dealing with mara and field matnr you could do this:
    data l_string.
    field-symbols <field> type any.
    l_string = in_string+10(18).
    assign l_string to <field> casting type matnr.
    (or assign l_string to <field> casting like mara-matnr).
    now <field> is a 'matnr' type field.
    If it's more complex please give some more info as I'm sure what you want can be done.

  • Dynamically assign value to a column in ALV LIST Display

    Hi all,
    How can I dynamically assign value to a column in ALV LIST Display without using classes and methods?
    Thanks,
    Ridhima

    Hi Vikranth,
    I am displaying one ALV list say with columns A and B.
    I have value in A but not in B. Now at runtime user selects one row, clicks on push button in application toolbar, then i have to display value in column B in the already displayed list.
    I searched and came to know it can be done with oops concept. but i am not using classes and methods.
    so how can i do this?
    Thanks,
    Ridhima.

  • How to assign values to Dynamic VO.

    Hi All,
    I have created a Dynamic VO and i have created 2 attributes(name and age) for it.
    Can i create this dynamic VO in Process form request of one of the CO class?
    Please let me know how to assign values to it......and display it and the page.?
    Thanks,
    Sowmya.

    Mukul
    I am trying to achieve something like below:
    Creating a Dynamic VO in my extended controller's ProcessRequest() method and attaching it to a MessageChoiceBean. In ProcessFormRequest() method based on some condition i have to change my Dynaic VO's whereClauseParam and re-execute it so that it will show some different set of values. Below is the code which i used. But after re-executing it my LOV is still showing old set of values. I have posted a query regd. the same but dint get much help. Kindly let me know, if you have any comments. Also Please find the link to my earlier post.
    Link: Re: Re-executed dynamic VO not showing new values
    * CODE *
    ProcessRequest()
    ViewObject vo = (ViewObject)am.createViewObjectFromQueryStmt("dummyVO","SELECT MEANING AS VALUE FROM HR_LOOKUPS WHERE LOOKUP_TYPE = :1");
    vo.setMaxFetchSize(-1);
    vo.setWhereClauseParam(0,"input1");
    vo.executeQuery();
    OAMessageChoiceBean mesBean=(OAMessageChoiceBean)webBean.findIndexedChild(webBean,"DemoChoiceItem");
    mesBean.setPickListCacheEnabled(false);
    mesBean.setPickListViewObjectDefinitionName("dummyVO ");
    mesBean.setPickListViewUsageName("dummyVO ");
    mesBean.setListDisplayAttribute("VALUE");
    mesBean.setListValueAttribute("VALUE");
    ProcessFormRequest()
    If the event is fired
    S.O.P(....);
    ViewObject vo1 = (ViewObject)am.findViewObject("dummyVO");
    vo1.clearCache();
    vo1.reset();
    vo1.setWhereClause(null);
    vo1.setWhereClauseParams(null);
    vo1.setWhereClauseParam(0,"input2");
    vo1.executeQuery();
    S.O.P(....);
    Thanks

  • Assign values dynamically to radio button

    I am creating an online test. I will need to display answer choices from the table. I created radio buttons for these answer choices and I could put the labels dynamically by using      
    Set_Radio_Button_Property('block_name.radio_group_name', 'radio_button1',LABEL,cursor_name.field_name);
    Now I have problem to set radio button values dynamically. Should I use when_radio_changed event?
    Any help would be appreciated.

    I really appreciate your help.
    My intention is to display the test on the screen.
    That means I need to display all questions and answer
    choices for each one dynamically. Based on the answer
    choice type (radio button or checkbox or drop down
    etc) I will need to assign the values to them and
    display on the screen. So far I could display
    questions and answer choices on the screen and set
    the label property for each radio button.
    Do you know what is the syntax to assign value to
    each radio button? First I will need to store user's
    answers in a table. For that I need to know what
    answer they selected. I wasn't sure how to do that.
    ThanksAs I said, the values cannot be assigned dynamically. Thus you will store the answers in code (perhaps in an array?) and your radio buttons will be 1,2,3,4 etc.
    In WHEN-RADIO-CHANGED you can retrieve the value from the array using the radio button value. Then store that value.
    e.g. Your screen shows
    What is the sound of one hand clapping?
    o Blue
    o Yes
    o 12
    These labels will be set dynamically, but the values for the radio buttons will be 1,2,3. If they pick "Yes", your radio button will be 2. You then get the value you really want from answer_array(2), where you put it when you retrieved the question details. Then you insert that into your users_answers table.

  • How can i dynamically assign values to the tld file

    How can i dynamically assign values to the tld file

    In the tld you write for the tag handler mention the following sub tags in the attribute
    <attribute>
    <name>xyz</name>
    <required>true</required>
    <rtexprvalue>true</rtexprvalue>
    </attribute>
    import the packagejavax.servlet.jsp.tagext.DynammicAttributes;
    add the method
    public void setDynamicAttribute(String rui, String localname, Object value) throws JspException
    <Your Required task>
    Its better if you SimpleTagSupport class to be extended.

  • Assigning values dynamically to drop down

    Hi,
    I have drop down for which i have to assign values dynamically, I am getting values as a form of Array list.

    Hi Venki,
    Say your ArrayList is al . Create a value attribute under the root node. Say test. Bind this test to the DropdownByKey UI element. You can populate test attribute like this.
    IWDAttributeInfo attributeInfo =
    wdContext.getNodeInfo().getAttribute(IPrivate<viewname>View.IContextElement.TEST);
    ISimpleTypeModifiable valuesType =
    attributeInfo.getModifiableSimpleType();
    IModifiableSimpleValueSet VS=
    valuesType.getSVServices().getModifiableSimpleValueSet();
           for (int i = 0; i < al.size(); i++) {
              VS.put(al.get(i),""+al.get(i));
    Regards
    Siva

  • Passing a context value to BAPI Import parameter in WebDynpro!

    Hi All,
    I have a small doubt here!
    I am trying to create a sales order using Webdynpro through BAPI.
    There i want to hard code the value of order type like, i want to fix the value before running the porgram itself i.e., statically i want to pass the value.
    What i have done is,
    created a Context variable and has assigned the value in the init() of view like,
    <b>wdContext.currentUIElementsElement().setDocType("ZORD")</b>
    and also changed the value attribute of InputField to the context variable called "DocType".
    But now we need to pass this context value to the BAPI Structure called ORDER_HEADER_IN  i.e, to the class "Bapisdhd1". with out the hardcode value it is working, but i want to pass the value before executing it self. so What i can do, can any body pls give sample line of coding.
    Thanks in advance,
    Regards,
    Sireesha.B

    Hi
    Have you bound instantiated the Bapi class?If not then do like this.
    BapiClass input = new BapiClass();
    wdContext.node<BAPINODE>.bind(input);
    Above code can be written in your Custom Controller or View's doinit.
    Then you write the code for doctype as given in the post above.
    Regards,
    Ajay

  • Assigning amount to months in Dynamic

    Hi all,
    I have a Dynamic ITAB, which is having month names as Dynamic columns. Now i want to assign some amount to each month.
    so, in the assignment part, i write :
    LOOP AT itab   INTO  wa_itab.
        ASSIGN COMPONENT  'MNT_AMT'  OF STRUCTURE <gwa_line> TO <gwa_field>.
        <gwa_field> = wa_itab-mnt_amt.  " this is my Amount value
        DO l_terms TIMES.  " l_terms is dynamic..
              ASSIGN COMPONENT  wa_flname OF STRUCTURE <gwa_line> TO <gwa_field>.
          <gwa_field> = wa_itab-mnt_amt.
        ENDDO.
    endloop.
    but the amount is assigning to the last month only.
    for ex: say i have months, starting from JANUARY to DECEMBER, in my case the amount is assigned to DECEMBer.
    i want to assign amount to each month.
    how to do that ?
    Thanks
    Kamala

    Hi,
    Do as below.
    Assume the month names are stored in an internal table with header line it_months with a single field month. Which means the content of the table it_months will be the colomns of the final interanal table of structure <gwa_line>.
    I assume there is a field which stores the month names in the internal table itab.
    The modified code is below.
    LOOP AT itab INTO wa_itab.
    ASSIGN COMPONENT 'MNT_AMT' OF STRUCTURE <gwa_line> TO <gwa_field>.
    <gwa_field> = wa_itab-mnt_amt. " this is my Amount value
    LOOP AT it_months WHERE month = wa_itab-month.
        ASSIGN COMPONENT it_months-month OF STRUCTURE <gwa_line> TO <gwa_field>.
        <gwa_field> =  wa_itab-mnt_amt.
      ENDLOOP.
    append <gwa_line> to <gt_line>.
    endloop.
    Hope this helps you,
    Murthy.

  • The returned value of BAPI call

    Hi, experts,
    I have a question about returned value of BAPI call.
    when the returned value is mapped as an attribute and this return value itsself is of the type: table of a certain structure. Is there any possibility that the value of this table still can be extracted from the mapped attribute? If it is possible, how?
    If not, how should this kind of situation be handled:
    when the returned value of the function at the backend has more one layer structure?
    Thanks and best regards,
    Fan

    In my experience you shouldn't use the service wizard to generate the context of such deeply nested structures. They don't generate or map correctly because it tries to put the table type as the type of the context attribute.
    Instead you should propery model the relationship in the context using nested nodes. Here is an example of address <-> address text where you can have multiple address texts per address.  From the service this was a returned nested table.
    ****BP Address and Address Text
      data lo_nd_bp_addr type ref to if_wd_context_node.
      data lo_nd_bp_addr_text type ref to if_wd_context_node.
      data lo_el_bp_addr type ref to if_wd_context_element.
    * navigate from <CONTEXT> to <BP_ADDR> via lead selection
      lo_nd_bp_addr = wd_context->get_child_node( name = wd_this->wdctx_bp_addr ).
      lo_nd_bp_addr->bind_table( wd_this->gt_bp_addr ).
    ****Add the Address Text Table as Child of each Address Context Record
      data element_set type wdr_context_element_set.
      field-symbols <wa_set> like line of element_set.
      field-symbols <wa_bp_addr> like line of wd_this->gt_bp_addr.
      element_set = lo_nd_bp_addr->get_elements( ).
      loop at element_set assigning <wa_set>.
        read table wd_this->gt_bp_addr index sy-tabix assigning <wa_bp_addr>.
        lo_nd_bp_addr_text = <wa_set>->get_child_node( name = if_componentcontroller=>wdctx_bp_addr_text ).
        lo_nd_bp_addr_text->bind_table( <wa_bp_addr>-t_text ).
      endloop.

  • How to assign values to a work area which is a Field Symbol?

    Hello Experts!
    I really need your help! this is the problem:
    I need to assign values to fields into a work area which is a field symbol. The values come from a flat file I uploaded and as I can't know the length I had to build the structure dynamically ( That's why I'm using FS). Each field comes from the file separated by ';', I tried using the SPLIT sentence:
    "SPLIT text AT ';' INTO TABLE <dyn_table>." but the values are assigned vertically into the same field instead of horizontally into each field of the table(field-symbol table).
    I know the name of the field dynamically
    (a TEXT + number) and I know I can't do this
    <dyn_wa>-TEXT1 or field_name = 'TEXT1' <dyn_wa>-(field_name).... ohhh I'm blocked, I don't seem to find the answer, please help!
    Thanks in advance!!
    Frinee

    Now that you have a table with the values, you can move them to the work area.
    data: begin of wa,
          fld1(20) type c,
          fld2(20) type c,
          fld3(20) type c,
    *     and so on
          end of wa.
    data: istr type table of string with header line.
    field-symbols: <fs>.
    split text at ';' into table istr.
    loop at istr.
    assign component sy-tabix of structure wa to <fs>.
    if sy-subrc <> 0.
    exit.
    endif.
    <fs> = istr.
    endloop.
    write:/ wa-fld1, wa-fld2, wa-fld3.
    Now, WA has the values in a horizontal fashion.
    Regards,
    Rich Heilman

Maybe you are looking for

  • Spry menubar works in IE, but not Firefox

    I added a very simple Spry horizontal menubar to the top of all pages in my web (I'm using DWCS4 and Spry 1.6). When I preview it in Firefox locally, it seems to work, but when it is uploaded to the web server it works in IE, but not in Firefox. Inst

  • Attempting to order online

    there is an internet bundle for 34.99. my verizon account will not display it as an option.I've spent two days attemting to resove this issue. i have discovered  "09-30-2011 02:13 PM I've been trying to change my phone plan online since last week but

  • Actions at item level

    Hello. We are implementing the opportunity management scenario in CRM 5.0. We are using the action profile for the sales assistant. We would also like to triger the actions from the item level. I have found so far that no action profile can be assign

  • Jsp:plugin applet code

    Hi all, I've been wondering if applets can be dynamically called from a jsp or servlet using strings in the applet code section. would this be good if a database was used to store the paths of the applets? i've tried this with a small applet in diffe

  • Maintaining or Editing xml files

    Hi All,         I am migrating a web application from tomcat to SAP WAS CE. In this web application there are some .xml files, porperty files. These xml files contains information like path of the log files, server urls, dabase information. Now the p