Dynamic setitem

Posted on 2011-02-14
Last Modified: 2013-12-26
version 10.5

user last input values for a particular report are already present
in string variables
ls_column_1,ls_column_2, ls_column3.... upto ls_column_16
in integer variable
Li_column_1, Li_column_2 upto Li_column_8 etc

when the user call the report next time we set his last saved values like this

FOR J  = 1 to a_stParm.s_field_req
      choose case J
            case 1
                  dw_1.setitem(1,"s_column_1", ls_column_1)
            case 2
            case 3
               and case upto 16
end choose

I wanted to get rid of repeated dw_1.setitem and did this, which worked.

arr_scolumn[] = {ls_column_1, ls_column_2,ls_column_3,ls_column_4,ls_column_5,ls_column_6,ls_column_7,ls_column_8,ls_column_9,ls_column_10,ls_column_11,ls_column_12,ls_column_13,ls_column_14,ls_column_15,ls_column_16}
arr_icolumn[] = {li_column_1, li_column_2,li_column_3,li_column_4,li_column_5,li_column_6,li_column_7,li_column_8}

FOR J  = 1 to a_stParm.s_field_req
      dw_1.setitem(1,'s_column_' + string(J), arr_scolumn[J])

FOR J  = 1 to a_stParm.i_field_req
      dw_1.setitem(1,'i_column_' + string(I), arr_icolumn[J])

This is working correctly.
My question is , can we get rid of array.

Can we do someghint like this

      dw_1.setitem(1,'s_column_' + string(J), EVALUATE (or whatever it may be) 'ls_column' + string(J))
In foxpro we can evaluate something by the sign '&', can we do something similiar here.

Question by:Mehram

Accepted Solution

loks earned 500 total points
ID: 34886570

Another way to eliminate the SetItem is by using ImportString function.

i.e you could build up a string using Tab as delimiter between the column values and calling ImportString to import the string into DW.

This is quicker than using setitem for 16 times.

Note: Need to be careful when preparing the string if data mismatch happens between the data & the column data type in the DW then an warning would be issued and might import only upto that point.


Author Comment

ID: 34886645

I am checking importstring.

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
My eclipse editor won't start ? 4 136
What is an NDK ? 3 93
HTML-Kit Question 5 90
netbeans not showing web project 3 75
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from ( Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now