cancel
Showing results for 
Search instead for 
Did you mean: 

Interactive Forms: pre-populate a drop-down list dynamically

Former Member
0 Kudos

Hello,

1.) can anybody tell me how to pre-populate a drop-down list with values from a DDIC table?

2.) How can I implement a dependance between two drop-down lists?

e.g: if 'aa' is choosen in drop-down-01, only 'a1' and 'a2'will be available in drop-down-02

if 'bb' is choosen in drop-down-01, only 'b1' and 'b2' will be available in drop-down-02

(note: this dependance must be dynamically, based on DDIC-Table values)

many thanks in advance,

Roger

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Roger,

use a code like this:

...

var loNodes;
if (lKey1 == 'car') loNodes=loNodes1;
else if (lKey1 == 'bike') loNodes=loNodes2;
else return;
var lLength = loNodes.length;
for (var i = 0; i < lLength; i++) {
  loNodesRow=loNodes.item(i).DATA.nodes;
  this.addItem(loNodesRow.item(0).value);
}

Regards

Michal

Former Member
0 Kudos

Hi Michal,

it works! you are really great!

thanks a lot!

regards

roger

Former Member
0 Kudos

Hi Michal,

How can we do this for a interactive form through <b>webDynprro Java</b>.

How can i prepopulate a second dropdown from the selected value in the first drop down.

As in WebDynpro Java, its not a value node, but an attribute. I am passing the values to the attribute from the model (backend) in the webDynrpo JAVA code using <i>attribute.put(value)</i> command for both the dropdowns. But I need to filter the second attribute values for the second drop down element as per the value selected.

Now what do i write in the java script for the second drop down, as the binded element is not a node but an attribute.

Hope this is clear.

Thanks andRegards,

Anto.

Former Member
0 Kudos

Hi I have 2 drop down lists.. in one dropdown list I have "Billable" and "Non Billable" , in second Dropdown list we will have Binding values with "Billable".... when we select "Billable" I need to get the data in Second Dropdown list from Database, and when we Select "Non Billable" then Dropdownlist should become a Inputfield (i.e Dropdown should turn to textfield)...and this should happen for each and every row....based on Index value....help me on this.....

Former Member
0 Kudos

Hi,

it is possible but it needs javaScripts in your adobe form.

I assume:

You have an internal table ITAB1 with columns: KEY1

You have an internal table ITAB2 with columns: KEY1, KEY2

You prefill these tables in your abap code and you send these tables by interface into your adobe form (attributes ITAB1 and ITAB2).

In your adobe form you have a drop-down list ddl1 and a drop-down list ddl2. Propertie List Items of ddl1 is binded to ITAB1.

On event change of ddl1 is a javaScript like this:

change();
function change() {
  if (xfa.event.newText==xfa.event.prevText) return;
  // Set value of ddl2 to null.
  ddl2.rawValue=null;
}

On event preopen of ddl2 is a javaScript like this:

var lKey1=ddl1.rawValue;
this.clearItems();
var loNodes = xfa.record.ITAB2.nodes;
var loNodesRow;
lLength = loNodes.length;
for (var i = 0; i < lLength; i++) {
  loNodesRow=loNodes.item(i).DATA.nodes;
  if (loNodesRow.item(0).value==lKey1)
    this.addItem(loNodesRow.item(1).value);
}

Regards

Michal

Former Member
0 Kudos

Hi,

thanks for this helpful answer.

Today I had a problem with our acrobat reader versions (sapnote 834573).

So I can test the JavaScript part soonest tomorrow. I hope I can ask you again in this thread if there are any greater problems.

many thanks!

regards

roger

Former Member
0 Kudos

Hi Michal, Hi all,

there is a problem in the preopen event:

I have a DropDown1 (ddl1)

static values: - car

- bike

and I have a DropDown2 (ddl2)..

Two internal tables are passed by the interface to the adobe form:

itab_car (one attribut: 'list'; values: car1, car2, car3)

itab_bike (one attribut: 'list; values: bike1, bike2, bike3)

If 'car' is chosen in DropDown1, the internal table 'itab_car' should be binded to Dropdown2.

If 'Bike' is chosen in DropDown1, the internal table 'itab_bike' should be binded to Dropdown2.

the event change of ddl1 works fine:

change();

function change() {

if (xfa.event.newText==xfa.event.prevText) return;

// Set value of ddl2 to null.

ddl2.rawValue=null;

}

but the event preopen for ddl2 doesn't work:

preopen();

function preopen() {

var lKey1=ddl1.rawValue;

this.clearItems();

var loNodes1 = xfa.record.itab_car.nodes;

var loNodes2 = xfa.record.itab_bike.nodes;

if (lKey1 == 'car')

???;

if (lKey1 == 'bike')

???;

}

Can you help me to complete the preopen event?

Many thanks!!

Former Member
0 Kudos

1) To populate the value of DD box, do following:

SELECT PERSA NAME1

from t500p

into table it_ t500p.

Loop the obtained internal table and pass the values to the additional values of the corresponding field in the form.

Loop at it_t500p.

add 1 to index.

ls_additional_data-fieldindex = index.

ls_additional_data-fieldname =' ZIPR_PERSA_KEY’.

ls_additional_data-fieldvalue = it_t500p -PERSA.

append ls_additional_data to additional_data.

ls_additional_data-fieldname =' ZIPR_PERSA_LABEL’.

concatenate it_t500p-PERSA ' (' it_t500p-NAME1 ')'

into ls_Additional_data-fieldvalue.

append ls_additional_data to additional_data.

Endloop.

2) To populate the values of second DD box, according to value of first DD box follow these steps:

On the Exit event of the first DD box:

xfa.record.CONTROL_PARAM.ISR_EVENT.value = "PERSA";

app.eval("event.target.SAPSubmit(false);");

Now, to catch these events you have to write ABAP Code in the method SCENARIO_PROCESS_USER_COMMAND.

Now, to catch these events you have to write ABAP Code in the method SCENARIO_PROCESS_USER_COMMAND.

Use Switch Case for performing desired operations on different events.

CASE user_command.

WHEN 'PERSA'.

data : lv_persa type persa.

READ TABLE additional_data INTO ls_additional_data

WITH KEY fieldname = ‘ZIPR_PERSA’.

Lv_persa = ls_additional_data-fieldvalue(4).

SELECT btrtl btext

FROM T001p

Into table it_t001p

WHERE werks = lv_ccode.

Loop at it_t001p.

add 1 to index.

Ls_additional_data-fieldindex = index.

ls_additional_data-fieldname = ‘ZIPR_BTRTL_KEY’.

ls_additional_data-fieldvalue = it_t001p -BTRTL.

append ls_additional_data to additional_data.

Ls_additional_data-fieldname =' ZIPR_BTRTL_LABEL’.

concatenate it_t001p-BTRTL ' (' it_t001p-BTEXT ')'

into ls_additional_data-fieldvalue.

append ls_additional_data to additional_data.

Endloop.

ENDCASE.

Hope this will help.

Regards,

Amit

Former Member
0 Kudos

hi,

thanks for this extensive answer. But there is one question. Where can I type in the ABAP code for the population of the DD. I realize interactive forms only with transaction SFP and the following ABAP coding:

How or where can I assign the values to the DD? In the following coding I could read the needed values from the database into an internal table, and then..?

many many thanks in advance

CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'

EXPORTING

i_name = '/VWK/Z_MABA_FORM'

IMPORTING

e_funcname = fm_name.

CALL FUNCTION 'FP_JOB_OPEN'

CHANGING

ie_outputparams = fp_outputparams

EXCEPTIONS

cancel = 1

usage_error = 2

system_error = 3

internal_error = 4

OTHERS = 5.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

  • Set form language and country (->form locale)

fp_docparams-langu = 'E'.

fp_docparams-country = 'US'.

fp_docparams-fillable = 'X'.

  • Now call the generated function module

CALL FUNCTION fm_name

EXPORTING

/1bcdwb/docparams = fp_docparams

z_tla_vw_export = wa_z_tla_vw_export

IMPORTING

/1bcdwb/formoutput = fp_formoutput

EXCEPTIONS

usage_error = 1

system_error = 2

internal_error = 3

OTHERS = 4.

  • Close spool job

CALL FUNCTION 'FP_JOB_CLOSE'

EXCEPTIONS

usage_error = 1

system_error = 2

internal_error = 3

OTHERS = 4.

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

EXPORTING

buffer = fp_formoutput-pdf TABLES

binary_tab = lt_att_content_hex.

CLASS cl_bcs DEFINITION LOAD.

  • create persistent sendig task

**********************************

lr_bcs = cl_bcs=>create_persistent( ).

  • create and set sender

***************************

lr_sender_int = cl_cam_address_bcs=>create_internet_address( email ).

lr_bcs->set_sender( lr_sender_int ).

  • create and set recipient

*****************************

*lo_recipient = cl_sapuser_bcs=>create( sy-uname ).

lr_receiver_int = cl_cam_address_bcs=>create_internet_address( email ).

lr_bcs->add_recipient( lr_receiver_int ).

[...]

[...]

[...]

Former Member
0 Kudos

Hi All:

I am trying to answer Maschine's question and raising another question for the forum.

Maschine, I believe the drop-down being discussed is for ISR forms which require some functional config as well and they are different from the adobe forms that you want rendered/e-mailed.

Can someone help me/us out please...can you bring these drop-downs from data tables in interactive forms in webdynpro applications?

I tried to map the list of countries using the SAP provided value help. I entered "$record.sap-vhlist.LAND1.item[*]" in the dynamic properties. The webdynpro context was mapped to the form interface context. But I didnt see the values in the DDL. What else needs to be done?

Thank you,

Fred.