Dynamic table declaration in FM
Hi Geeks,
I am calling a FM from a program where the FM should get the structure data and set that data into a single line with delimiters and send it out. The table structure can be anything. So how can I declare that table structure data (in tables tab in FM). Could somebody help me with this.
Thanks,
Kiran.
Hi Rich,
Thanks a lot for your help. Here is the code.
PARAMETERS p_delim TYPE sy-input OBLIGATORY DEFAULT '|'.
DATA: rec_hdr TYPE zwm_sch_waybill_fhdr.
DATA: rec_a01 TYPE zwm_sch_waybill_a01.
DATA: rec_a02 TYPE zwm_sch_waybill_a02.
DATA: rec_b01 TYPE zwm_sch_waybill_b01.
DATA: rec_b02 TYPE zwm_sch_waybill_b02.
DATA: rec_b03 TYPE zwm_sch_waybill_b03.
DATA: rec_b04 TYPE zwm_sch_waybill_b04.
DATA: rec_c01 TYPE zwm_sch_waybill_c01.
DATA: rec_c02 TYPE zwm_sch_waybill_c02.
DATA: rec_c03 TYPE zwm_sch_waybill_c03.
DATA: rec_d01 TYPE zwm_sch_waybill_d01.
DATA: rec_d02 TYPE zwm_sch_waybill_d02.
DATA: rec_d03 TYPE zwm_sch_waybill_d03.
DATA: rec_d04 TYPE zwm_sch_waybill_d04.
DATA: rec_e01 TYPE zwm_sch_waybill_e01.
DATA: rec_e02 TYPE zwm_sch_waybill_e02.
DATA: rec_e03 TYPE zwm_sch_waybill_e03.
DATA: rec_e04 TYPE zwm_sch_waybill_e04.
DATA: rec_f01 TYPE zwm_sch_waybill_f01.
DATA: rec_g01 TYPE zwm_sch_waybill_g01.
DATA: rec_ftr TYPE zwm_sch_waybill_fftr.
DATA: rec_fixed TYPE string.
DATA: rec_delimited TYPE string.
DATA: BEGIN OF rec_struc OCCURS 0.
INCLUDE STRUCTURE zfile_struc.
DATA: END OF rec_struc.
rec_hdr-rectype = 'FHDR' .
rec_hdr-filetype = 'LP' .
rec_hdr-fformat = 'DLM' .
rec_hdr-partenrid = 'SCEE' .
rec_hdr-testmode = 'T' .
rec_hdr-docver = 7 .
rec_hdr-ftimezone = 'GMT' .
rec_hdr-ftimestamp = 20081801110244 .
rec_hdr-dummy1 = '0000000000' .
rec_a01-rectype = 'A01' .
rec_a01-doctype = 'LP' .
rec_a01-waybno = 1234567890 .
rec_a01-clirefno1 = 'Sender ref 1' .
rec_a01-clirefno2 = 'Sender ref 2' .
rec_a01-clireftype = 5 .
rec_a01-msgfunc = 6 .
rec_a02-rectype = 'A02' .
rec_a02-clisendate = 20080118 .
rec_a02-clideliverdate = '' .
rec_a02-clisentime = '11:08' .
rec_a02-clidelivertime = '' .
rec_b01-rectype = 'B01' .
rec_b01-sendcc = 'PL' .
rec_b01-sendid = 1234567 .
rec_b01-sendsop = 9999999 .
rec_b02-rectype = 'B02' .
rec_b02-sendpost = '12-345' .
rec_b02-senddept = '' .
rec_b02-sendcity = '' .
rec_b02-sendstreet = 'Streetname' .
rec_ftr-rectype = 'FFTR' .
rec_ftr-filedocs = 99 .
PERFORM delimit USING rec_hdr.
PERFORM delimit USING rec_a01.
PERFORM delimit USING rec_a02.
PERFORM delimit USING rec_b01.
PERFORM delimit USING rec_b02.
PERFORM delimit USING rec_ftr.
FORM delimit USING inrec.
data: v_length type sy-tleng.
CALL FUNCTION 'Z_FILENAME_CONTENT_SETUP'
EXPORTING
delimiter = p_delim
IMPORTING
delimited_data = rec_delimited
length = v_length
TABLES
struc = inrec
Importing declaration
rec_delimited type string
length type sy-tleng
exporting declaration
delimiter like sy-input
tables dec
struc type standard table
The data I am passing is a structure and not a table but in the FM we have to declare it as internal table.
Thanks,
Kiran.
Similar Messages
-
Error while insert data using execute immediate in dynamic table in oracle
Error while insert data using execute immediate in dynamic table created in oracle 11g .
first the dynamic nested table (op_sample) was created using the executed immediate...
object is
CREATE OR REPLACE TYPE ASI.sub_mark AS OBJECT (
mark1 number,
mark2 number
t_sub_mark is a class of type sub_mark
CREATE OR REPLACE TYPE ASI.t_sub_mark is table of sub_mark;
create table sam1(id number,name varchar2(30));
nested table is created below:
begin
EXECUTE IMMEDIATE ' create table '||op_sample||'
(id number,name varchar2(30),subject_obj t_sub_mark) nested table subject_obj store as nest_tab return as value';
end;
now data from sam1 table and object (subject_obj) are inserted into the dynamic table
declare
subject_obj t_sub_mark;
begin
subject_obj:= t_sub_mark();
EXECUTE IMMEDIATE 'insert into op_sample (select id,name,subject_obj from sam1) ';
end;
and got the below error:
ORA-00904: "SUBJECT_OBJ": invalid identifier
ORA-06512: at line 7
then when we tried to insert the data into the dynam_table with the subject_marks object as null,we received the following error..
execute immediate 'insert into '||dynam_table ||'
(SELECT887684 wrote:
ORA-00904: "SUBJECT_OBJ": invalid identifier
ORA-06512: at line 7The problem is that your variable subject_obj is not in scope inside the dynamic SQL you are building. The SQL engine does not know your PL/SQL variable, so it tries to find a column named SUBJECT_OBJ in your SAM1 table.
If you need to use dynamic SQL for this, then you must bind the variable. Something like this:
EXECUTE IMMEDIATE 'insert into op_sample (select id,name,:bind_subject_obj from sam1) ' USING subject_obj;Alternatively you might figure out to use static SQL rather than dynamic SQL (if possible for your project.) In static SQL the PL/SQL engine binds the variables for you automatically. -
How to declare Dynamic table in Tables Parameters of a Function Module...
Hi Gurus,
I would like to Know how to declare a Dynamic table in Tables parameters of a Function Module.
so that it should be able to hold any table data ....
I have tried all possible ways of trying to assign fields-symbol like declarations which doesnt allow here ...
plz Dont reply with the basics of creating dynamic internal tables, coz my case is not an Internal table it is FM table parameter declaration.....Hi,
If you are requirement is to create a function module with tables parameter having a generic line type i.e. no specific line type
just declare it with a name under Parameter name with out specifying the type.
A reference function module with such parameter, i would quote is the standard GUI_UPLOAD/ GUI_DOWNLOAD where the parameters specified under TABLES are generic.
If you want to process the values passed to these parameters in the source code of function module, field symbols would be a preferable option.
Regards,
Sharath Panuganti -
Declaring field from the internally declared table into dynamic table
Hi Gurus,
I need your help on one of my requirements.
Due to dynamic nature of ALV report, I have used a dynamic internal table to pass it to function module.
In dynamic tables, I am trying to have one column form the internal table which is being calculated by substracting 2 fields( i,e. diff = wa_stk-labst - wa_stk-omeng). Is it possible to include that field (diff) which is coming from the internally declared table(i_out) into the dynamic table decleration. Please assist.
Thanks in AdvanceHi,
Suppose your dynamic table is of type table.
When you pass the data from internal table I_OUT to your dynamic table it will get the same structure as of your internally declared table IT_OUT which is calculated by subtracting 2 fields.
What you can do is create one more field in I_OUT which holds the value of the subtracted amount then pass the table IT_OUT to your dynamic table.
Thanks
Bhanu -
HR Logical database PNP. OO to fill table dynamic table from PNP ?
Hi all
I want to get some stuff from the HR logical database into a dynamic table
Here's a real simple example that writes info out to a normal list.
(report is based on using Logical DB PNP)
tables: pernr.
INFOTYPES: 0001, "Organizational Assignment
0002. "Personal Data
SELECT-OPTIONS: language FOR p0002-sprsl.
INITIALIZATION.
pnptimed = 'D'.
GET pernr.
PROVIDE * FROM p0002 BETWEEN pn-begda AND pn-endda.
CHECK language.
WRITE: / p0002-pernr,
sy-vline,
p0001-ename,
sy-vline,
p0002-sprsl,
sy-vline,
p0002-gbdat.
ENDPROVIDE.
endform.
Now what I want to do is replace the write stuff by appending the entries into a dynamic table which I will display as an ALV Grid.
so I add my structure in the data declarations
types: begin of s_elements,
pernr type p0002-pernr,
ename type p0001-ename,
sprsl type p0002-sprsl,
gbdat type p0002-gbdat.
drop_down_handle type int4.
types: end of s_elements.
include zz_jimbo_incl.
build the dynamic table
create data dref type s_elements.
assign dref->* to <fs>.
i_routine = 'POPULATE_DYNAMIC_ITAB'.*
i_names = 'NAME_COLUMNS'.
i_gridtitle = 'HR TEST'.
invoker = sy-repid.
i_zebra = 'X '.
i_edit = ' '.
call function 'ZZ_CALL_SCREEN'
exporting
invoker = invoker
my_line = <fs>
i_gridtitle = i_gridtitle
i_edit = i_edit
i_zebra = i_zebra
i_names = i_names
i_routine = i_routine
importing
z_object = z_object
dy_table = dy_table.
Now to populate the dynamic Itab the routine below is entered.
form populate_dynamic_itab changing dy_table.
assign dy_table->* to <dyn_table>.
create data dy_line like line of <dyn_table>.
assign dy_line->* to <dyn_wa>.
However I can't use GET / PROVIDE / ENDPROVIDE in a Form.
Anyway round this ---seems HR has an aversion to OO.
Cheers
jimboHi,
well, GET_PERNR is a so called event_statement. It has nothing to do with ABAP 00.
Normally it will be like this:
START-OF-SELECTION.
GET_PERNR.
PROVIDE ....
END-OF-SELECTION.
-> and here the CALL SCREEN NNNN for ALV-Display.
Provide-statements you can use in forms of course, and as many times you want during GET and END-OF-SELECTION.
But as I understood : you just want to save the write-statements?
I always develop a DDIC-Structure, declarate the data objects in the programm, read the data via Provide into the infotypes, and then make a move-corresponding to my structure. and display it.
Normally no problem.
kind regards
maik -
Why dynamic table creation with struts working only for JDK1.3.1_02 version
Row
import java.util.Vector;
public class Row
private static int colsize;
private Column[] columns;
public void setColumns(Column[] columns)
System.out.println("SetColumns");
this.columns = columns;
public void setColumn(int i, Column column)
System.out.println("setting"+ i+"th column"+column);
public Column[] getColumns()
return null;
public Column getColumns(int i)
System.out.println("Column"+i);
System.out.println("Colsize"+colsize);
if(columns == null)
columns= new Column[colsize];
if(columns[i] == null)
columns[i] = new Column();
return columns;
public int getColsize()
return colsize;
public static void setColsize(int size)
colsize = size;
Column:
public class Column
private String value;
public void setValue(String value)
System.out.println("Value="+value);
this.value = value;
public String getValue()
return value;
ApplicationResources:
button.cancel=Cancel
button.confirm=Confirm
button.reset=Reset
button.save=Save
database.load=Cannot load database from {0}
error.database.missing=<li>User database is missing, cannot validate logon credentials</li>
error.fromAddress.format=<li>Invalid format for From Address</li>
error.fromAddress.required=<li>From Address is required</li>
error.fullName.required=<li>Full Name is required</li>
error.host.required=<li>Mail Server is required</li>
error.noSubscription=<li>No Subscription bean in user session</li>
error.password.required=<li>Password is required</li>
error.password2.required=<li>Confirmation password is required</li>
error.password.match=<li>Password and confirmation password must match</li>
error.password.mismatch=<li>Invalid username and/or password, please try again</li>
error.replyToAddress.format=<li>Invalid format for Reply To Address</li>
error.transaction.token=<li>Cannot submit this form out of order</li>
error.type.invalid=<li>Server Type must be 'imap' or 'pop3'</li>
error.type.required=<li>Server Type is required</li>
error.username.required=<li>Username is required</li>
error.username.unique=<li>That username is already in use - please select another</li>
errors.footer=</ul><hr>
errors.header=<h3><font color="red">Validation Error</font></h3>You must correct the following error(s) before proceeding:<ul>
errors.ioException=I/O exception rendering error messages: {0}
heading.autoConnect=Auto
heading.subscriptions=Current Subscriptions
heading.host=Host Name
heading.user=User Name
heading.type=Server Type
heading.action=Action
index.heading=MailReader Demonstration Application Options
index.logon=Log on to the MailReader Demonstration Application
index.registration=Register with the MailReader Demonstration Application
index.title=MailReader Demonstration Application (Struts 1.0-b1)
index.tour=A Walking Tour of the Example Application
linkSubscription.io=I/O Error: {0}
linkSubscription.noSubscription=No subscription under attribute {0}
linkUser.io=I/O Error: {0}
linkUser.noUser=No user under attribute {0}
logon.title=MailReader Demonstration Application - Logon
mainMenu.heading=Main Menu Options for
mainMenu.logoff=Log off MailReader Demonstration Application
mainMenu.registration=Edit your user registration profile
mainMenu.title=MailReader Demonstration Application - Main Menu
option.imap=IMAP Protocol
option.pop3=POP3 Protocol
prompt.autoConnect=Auto Connect:
prompt.fromAddress=From Address:
prompt.fullName=Full Name:
prompt.mailHostname=Mail Server:
prompt.mailPassword=Mail Password:
prompt.mailServerType=Server Type:
prompt.mailUsername=Mail Username:
prompt.password=Password:
prompt.password2=(Repeat) Password:
prompt.replyToAddress=Reply To Address:
prompt.username=Username:
registration.addSubscription=Add
registration.deleteSubscription=Delete
registration.editSubscription=Edit
registration.title.create=Register for the MailReader Demostration Application
registration.title.edit=Edit Registration for the MailReader Demonstration Application
subscription.title.create=Create New Mail Subscription
subscription.title.delete=Delete Existing Mail Subscription
subscription.title.edit=Edit Existing Mail Subscription
LogonForm
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
public class LogonForm extends ActionForm
private String username;
private String password;
private String errors;
public String getUsername()
return username;
public void setUsername(String username)
this.username = username;
public void setPassword(String password)
this.password = password;
public String getPassword()
return password;
public String getErrors()
return errors;
public void setErrors(String errors)
this.errors = errors;
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if ((username == null) || (username.length() < 1))
errors.add("username", new ActionError("error.username.required"));
if ((password == null) || (password.length() < 1))
errors.add("password", new ActionError("error.password.required"));
return errors;
TableForm
import org.apache.struts.action.ActionForm;
import java.util.Vector;
public class TableForm extends ActionForm
private static int rowsize;
private Row[] rows;
public Row getRows(int i)
System.out.println("Row"+i);
System.out.println("Rowsize"+rowsize);
if(rows == null)
rows = new Row[rowsize];
if(rows[i] == null)
rows[i] = new Row();
return rows[i];
public Row[] getRows()
return null;
public void setRows(Row[] rows)
System.out.println("SetRows");
// this.rows=rows;
public static void setRowsize(int size)
rowsize = size;
public int getRowSize()
return rowsize;
LogonAction
import java.io.IOException;
import java.util.Hashtable;
import java.util.Locale;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.util.MessageResources;
public class LogonAction extends Action
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
LogonForm logonForm = (LogonForm) form;
System.out.println(logonForm);
System.out.println(logonForm.getUsername());
System.out.println(logonForm.getPassword());
if(logonForm.getUsername().equals("test") && logonForm.getPassword().equals("test"))
//TableForm tform = new TableForm();
//tform.setRowsize(2);
//tform.getRows(0).setColsize(2);
//tform.getRows(1).setColsize(2);
//request.getSession().setAttribute("tableForm",tform);
System.out.println("Table Form setRowSize");
TableForm.setRowsize(2);
System.out.println("Table Form set ColSize");
Row.setColsize(2);
System.out.println("Returning success");
return mapping.findForward("success");
else
ActionErrors errors = new ActionErrors();
errors.add("password",
new ActionError("error.password.mismatch"));
saveErrors(request, errors);
//logonForm.setErrors("LoginError");
return mapping.findForward("failure");
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">
<!--
This is the Struts configuration file for the example application,
using the proposed new syntax.
NOTE: You would only flesh out the details in the "form-bean"
declarations if you had a generator tool that used them to create
the corresponding Java classes for you. Otherwise, you would
need only the "form-bean" element itself, with the corresponding
"name" and "type" attributes.
-->
<struts-config>
<form-beans>
<!-- Logon form bean -->
<form-bean name="logonForm"
type="LogonForm"/>
<form-bean name="tableForm"
type="TableForm"/>
<form-bean name="profileForm"
type="ProfileForm"/>
</form-beans>
<global-forwards>
<forward name="success" path="/Profile.jsp"/>
</global-forwards>
<!-- ========== Action Mapping Definitions ============================== -->
<action-mappings>
<!-- Edit user registration -->
<action path="/logon"
type="LogonAction"
name="logonForm"
scope="request"
validate="false"
input="/Test.jsp">
<forward name="success" path="/Table.jsp"/>
<forward name="failure" path="/Test.jsp"/>
</action>
<action path="/table"
type="TableAction"
name="tableForm"
scope="request"
validate="false">
<forward name="success" path="/Bean.jsp"/>
<forward name="failure" path="/Table.jsp"/>
</action>
<action path="/profile"
type="ProfileAction"
name="profileForm"
scope="request"
validate="false"
parameter="method">
<forward name="edit" path="/EditProfile.jsp"/>
<forward name="show" path="/Profile.jsp"/>
</action>
</action-mappings>
</struts-config>
Test.jsp
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html:html locale="true">
<html:form action="/logon" >
<center>
<table>
<tr>
<td> Username </td>
<td> <html:text property="username" size="16" maxlength="16"/> </td>
<td> <html:errors property="username" /> </td>
</tr>
<tr>
<td> Password </td>
<td> <html:password property="password" size="16" maxlength="16"
redisplay="false"/> </td>
<td><html:errors property="password" /> </td>
</tr>
</table>
</center>
<center> <html:submit property="submit" value="Submit"/> </center>
</html:form>
</html:html>
Table.jsp
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html:html locale="true">
<html:form action="/table" >
<center>
<table>
<tr>
<td> <html:text property="rows[0].columns[0].value" /> </td>
<td> <html:text property="rows[0].columns[1].value" /></td>
</tr>
<tr>
<td> <html:text property="rows[1].columns[0].value" /> </td>
<td> <html:text property="rows[1].columns[1].value" /></td>
</tr>
</table>
</center>
<center> <html:submit property="submit" value="Submit"/> </center>
</html:form>
</html:html>The above application runs only with JDK1.3.1_02 and not with any other version. This application is creating dynamic table using struts.
Can anybody help me on the same
also appending web.xml contents:
<?xml version="1.0" ?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<!-- Action Servlet Configuration -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>validate</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<!-- Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!--Welcome file list starts here -->
<welcome-file-list>
<welcome-file>
/test.jsp
</welcome-file>
</welcome-file-list>
<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
</web-app>
validate-rules.xml
<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.0//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_0.dtd">
<!--
This file contains the default Struts Validator pluggable validator
definitions. It should be placed somewhere under /WEB-INF and
referenced in the struts-config.xml under the plug-in element
for the ValidatorPlugIn.
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml,
/WEB-INF/validation.xml"/>
</plug-in>
These are the default error messages associated with
each validator defined in this file. They should be
added to your projects ApplicationResources.properties
file or you can associate new ones by modifying the
pluggable validators msg attributes in this file.
# Struts Validator Error Messages
errors.required={0} is required.
errors.minlength={0} can not be less than {1} characters.
errors.maxlength={0} can not be greater than {1} characters.
errors.invalid={0} is invalid.
errors.byte={0} must be a byte.
errors.short={0} must be a short.
errors.integer={0} must be an integer.
errors.long={0} must be a long.
errors.float={0} must be a float.
errors.double={0} must be a double.
errors.date={0} is not a date.
errors.range={0} is not in the range {1} through {2}.
errors.creditcard={0} is an invalid credit card number.
errors.email={0} is an invalid e-mail address.
-->
<form-validation>
<global>
<validator name="required"
classname="org.apache.struts.validator.FieldChecks"
method="validateRequired"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
javax.servlet.http.HttpServletRequest"
msg="errors.required">
<javascript><![CDATA[
function validateRequired(form) {
var isValid = true;
var focusField = null;
var i = 0;
var fields = new Array();
oRequired = new required();
for (x in oRequired) {
var field = form[oRequired[x][0]];
if (field.type == 'text' ||
field.type == 'textarea' ||
field.type == 'file' ||
field.type == 'select-one' ||
field.type == 'radio' ||
field.type == 'password') {
var value = '';
// get field's value
if (field.type == "select-one") {
var si = field.selectedIndex;
if (si >= 0) {
value = field.options[si].value;
} else {
value = field.value;
if (trim(value).length == 0) {
if (i == 0) {
focusField = field;
fields[i++] = oRequired[x][1];
isValid = false;
if (fields.length > 0) {
focusField.focus();
alert(fields.join('\n'));
return isValid;
// Trim whitespace from left and right sides of s.
function trim(s) {
return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
]]>
</javascript>
</validator>
<validator name="requiredif"
classname="org.apache.struts.validator.FieldChecks"
method="validateRequiredIf"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
msg="errors.required">
</validator>
<validator name="minlength"
classname="org.apache.struts.validator.FieldChecks"
method="validateMinLength"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.minlength">
<javascript><![CDATA[
function validateMinLength(form) {
var isValid = true;
var focusField = null;
var i = 0;
var fields = new Array();
oMinLength = new minlength();
for (x in oMinLength) {
var field = form[oMinLength[x][0]];
if (field.type == 'text' ||
field.type == 'textarea') {
var iMin = parseInt(oMinLength[x][2]("minlength"));
if ((trim(field.value).length > 0) && (field.value.length < iMin)) {
if (i == 0) {
focusField = field;
fields[i++] = oMinLength[x][1];
isValid = false;
if (fields.length > 0) {
focusField.focus();
alert(fields.join('\n'));
return isValid;
}]]>
</javascript>
</validator>
<validator name="maxlength"
classname="org.apache.struts.validator.FieldChecks"
method="validateMaxLength"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.maxlength">
<javascript><![CDATA[
function validateMaxLength(form) {
var isValid = true;
var focusField = null;
var i = 0;
var fields = new Array();
oMaxLength = new maxlength();
for (x in oMaxLength) {
var field = form[oMaxLength[x][0]];
if (field.type == 'text' ||
field.type == 'textarea') {
var iMax = parseInt(oMaxLength[x][2]("maxlength"));
if (field.value.length > iMax) {
if (i == 0) {
focusField = field;
fields[i++] = oMaxLength[x][1];
isValid = false;
if (fields.length > 0) {
focusField.focus();
alert(fields.join('\n'));
return isValid;
}]]>
</javascript>
</validator>
<validator name="mask"
classname="org.apache.struts.validator.FieldChecks"
method="validateMask"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.invalid">
<javascript><![CDATA[
function validateMask(form) {
var isValid = true;
var focusField = null;
var i = 0;
var fields = new Array();
oMasked = new mask();
for (x in oMasked) {
var field = form[oMasked[x][0]];
if ((field.type == 'text' ||
field.type == 'textarea') &&
(field.value.length > 0)) {
if (!matchPattern(field.value, oMasked[x][2]("mask"))) {
if (i == 0) {
focusField = field;
fields[i++] = oMasked[x][1];
isValid = false;
if (fields.length > 0) {
focusField.focus();
alert(fields.join('\n'));
return isValid;
function matchPattern(value, mask) {
return mask.exec(value);
}]]>
</javascript>
</validator>
<validator name="byte"
classname="org.apache.struts.validator.FieldChecks"
method="validateByte"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.byte"
jsFunctionName="ByteValidations">
<javascript><![CDATA[
function validateByte(form) {
var bValid = true;
var focusField = null;
var i = 0;
var fields = new Array();
oByte = new ByteValidations();
for (x in oByte) {
var field = form[oByte[x][0]];
if (field.type == 'text' ||
field.type == 'textarea' ||
field.type == 'select-one' ||
field.type == 'radio') {
var value = '';
// get field's value
if (field.type == "select-one") {
var si = field.selectedIndex;
if (si >= 0) {
value = field.options[si].value;
} else {
value = field.value;
if (value.length > 0) {
if (!isAllDigits(value)) {
bValid = false;
if (i == 0) {
focusField = field;
fields[i++] = oByte[x][1];
} else {
var iValue = parseInt(value);
if (isNaN(iValue) || !(iValue >= -128 && iValue <= 127)) {
if (i == 0) {
focusField = field;
fields[i++] = oByte[x][1];
bValid = false;
if (fields.length > 0) {
focusField.focus();
alert(fields.join('\n'));
return bValid;
}]]>
</javascript>
</validator>
<validator name="short"
classname="org.apache.struts.validator.FieldChecks"
method="validateShort"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.short"
jsFunctionName="ShortValidations">
<javascript><![CDATA[
function validateShort(form) {
var bValid = true;
var focusField = null;
var i = 0;
var fields = new Array();
oShort = new ShortValidations();
for (x in oShort) {
var field = form[oShort[x][0]];
if (field.type == 'text' ||
field.type == 'textarea' ||
field.type == 'select-one' ||
field.type == 'radio') {
var value = '';
// get field's value
if (field.type == "select-one") {
var si = field.selectedIndex;
if (si >= 0) {
value = field.options[si].value;
} else {
value = field.value;
if (value.length > 0) {
if (!isAllDigits(value)) {
bValid = false;
if (i == 0) {
focusField = field;
fields[i++] = oShort[x][1];
} else {
var iValue = parseInt(value);
if (isNaN(iValue) || !(iValue >= -32768 && iValue <= 32767)) {
if (i == 0) {
focusField = field;
fields[i++] = oShort[x][1];
bValid = false;
if (fields.length > 0) {
focusField.focus();
alert(fields.join('\n'));
return bValid;
}]]>
</javascript>
</validator>
<validator name="integer"
classname="org.apache.struts.validator.FieldChecks"
method="validateInteger"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.integer"
jsFunctionName="IntegerValidations">
<javascript><![CDATA[
function validateInteger(form) {
var bValid = true;
var focusField = null;
var i = 0;
var fields = new Array();
oInteger = new IntegerValidations();
for (x in oInteger) {
var field = form[oInteger[x][0]];
if (field.type == 'text' ||
field.type == 'textarea' ||
field.type == 'select-one' ||
field.type == 'radio') {
var value = '';
// get field's value
if (field.type == "select-one") {
var si = field.selectedIndex;
if (si >= 0) {
value = field.options[si].value;
} else {
value = field.value;
if (value.length > 0) {
if (!isAllDigits(value)) {
bValid = false;
if (i == 0) {
focusField = field;
fields[i++] = oInteger[x][1];
} else {
var iValue = parseInt(value);
if (isNaN(iValue) || !(iValue >= -2147483648 && iValue <= 2147483647)) {
if (i == 0) {
focusField = field;
fields[i++] = oInteger[x][1];
bValid = false;
if (fields.length > 0) {
focusField.focus();
alert(fields.join('\n'));
return bValid;
function isAllDigits(argvalue) {
argvalue = argvalue.toString();
var validChars = "0123456789";
var startFrom = 0;
if (argvalue.substring(0, 2) == "0x") {
validChars = "0123456789abcdefABCDEF";
startFrom = 2;
} else if (argvalue.charAt(0) == "0") {
validChars = "01234567";
startFrom = 1;
} else if (argvalue.charAt(0) == "-") {
startFrom = 1;
for (var n = startFrom; n < argvalue.length; n++) {
if (validChars.indexOf(argvalue.substring(n, n+1)) == -1) return false;
return true;
}]]>
</javascript>
</validator>
<validator name="long"
classname="org.apache.struts.validator.FieldChecks"
method="validateLong"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.long"/>
<validator name="float"
classname="org.apache.struts.validator.FieldChecks"
method="validateFloat"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.float"
jsFunctionName="FloatValidations">
<javascript><![CDATA[
function validateFloat(form) {
var bValid = true;
var focusField = null;
var i = 0;
var fields = new Array();
oFloat = new FloatValidations();
for (x in oFloat) {
var field = form[oFloat[x][0]];
if (field.type == 'text' ||
field.type == 'textarea' ||
field.type == 'select-one' ||
field.type == 'radio') {
var value = '';
// get field's value
if (field.type == "select-one") {
var si = field.selectedIndex;
if (si >= 0) {
value = field.options[si].value;
} else {
value = field.value;
if (value.length > 0) {
// remove '.' before checking digits
var tempArray = value.split('.');
var joinedString= tempArray.join('');
if (!isAllDigits(joinedString)) {
bValid = false;
if (i == 0) {
focusField = field;
fields[i++] = oFloat[x][1];
} else {
var iValue = parseFloat(value);
if (isNaN(iValue)) {
if (i == 0) {
focusField = field;
fields[i++] = oFloat[x][1];
bValid = false;
if (fields.length > 0) {
focusField.focus();
alert(fields.join('\n'));
return bValid;
}]]>
</javascript>
</validator>
<validator name="double"
classname="org.apache.struts.validator.FieldChecks"
method="validateDouble"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.double"/>
<validator name="date"
classname="org.apache.struts.validator.FieldChecks"
method="validateDate"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.date"
jsFunctionName="DateValidations">
<javascript><![CDATA[
function validateDate(form) {
var bValid = true;
var focusField = null;
var i = 0;
var fields = new Array();
oDate = new DateValidations();
for (x in oDate) {
var value = form[oDate[x][0]].value;
var datePattern = oDate[x][2]("datePatternStrict");
if ((form[oDate[x][0]].type == 'text' ||
form[oDate[x][0]].type == 'textarea') &&
(value.length > 0) &&
(datePattern.length > 0)) {
var MONTH = "MM";
var DAY = "dd";
var YEAR = "yyyy";
var orderMonth = datePattern.indexOf(MONTH);
var orderDay = datePattern.indexOf(DAY);
var orderYear = datePattern.indexOf(YEAR);
if ((orderDay < orderYear && orderDay > orderMonth)) {
var iDelim1 = orderMonth + MONTH.length;
var iDelim2 = orderDay + DAY.length;
var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
if (iDelim1 == orderDay && iDelim2 == orderYear) {
dateRegexp = new RegExp("^(\\d{2})(\\d{2})(\\d{4})$");
} else if (iDelim1 == orderDay) {
dateRegexp = new RegExp("^(\\d{2})(\\d{2})[" + delim2 + "](\\d{4})$");
} else if (iDelim2 == orderYear) {
dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})(\\d{4})$");
} else {
dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{4})$");
var matched = dateRegexp.exec(value);
if(matched != null) {
if (!isValidDate(matched[2], matched[1], matched[3])) {
if (i == 0) {
focusField = form[oDate[x][0]];
fields[i++] = oDate[x][1];
bValid = false;
} else {
if (i == 0) {
focusField = form[oDate[x][0]];
fields[i++] = oDate[x][1];
bValid = false;
} else if ((orderMonth < orderYear && orderMonth > orderDay)) {
var iDelim1 = orderDay + DAY.length;
var iDelim2 = orderMonth + MONTH.length;
var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
if (iDelim1 == orderMonth && iDelim2 == orderYear) {
dateRegexp = new RegExp("^(\\d{2})(\\d{2})(\\d{4})$");
} else if (iDelim1 == orderMonth) {
dateRegexp = new RegExp("^(\\d{2})(\\d{2})[" + delim2 + "](\\d{4})$");
} else if (iDelim2 == orderYear) {
dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})(\\d{4})$");
} else {
dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{4})$");
var matched = dateRegexp.exec(value);
if(matched != null) {
if (!isValidDate(matched[1], matched[2], matched[3])) {
if (i == 0) {
focusField = form[oDate[x][0]];
fields[i++] = oDate[x][1];
bValid = false;
} else {
if (i == 0) {
focusField = form[oDate[x][0]];
fields[i++] = oDate[x][1];
bValid = false;
} else if ((orderMonth > orderYear && orderMonth < orderDay)) {
var iDelim1 = orderYear + YEAR.length;
var iDelim2 = orderMonth + MONTH.length;
var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
if (iDelim1 == orderMonth && iDelim2 == orderDay) {
dateRegexp = new RegExp("^(\\d{4})(\\d{2})(\\d{2})$");
} else if (iDelim1 == orderMonth) {
dateRegexp = new RegExp("^(\\d{4})(\\d{2})[" + delim2 + "](\\d{2})$");
} else if (iDelim2 == orderDay) {
dateRegexp = new RegExp("^(\\d{4})[" + delim1 + "](\\d{2})(\\d{2})$");
} else {
dateRegexp = new Reg -
Problem with Dynamic Table Name
Hello all,
I am having trouble using a dynamic table name. I have the following code.....
declare l_cur sys_refcursor;
l_ID int;
l_tableName varchar(30);
BEGIN
open l_cur for
select hkc.ColumnID, mapping from &HKAPPDB_Schema_Name..doctablemapping ddm
inner join &HKDB_Schema_Name..HKColumns hkc on hkc.doctablemappingid = ddm.id
where ddm.id > 0;
LOOP
FETCH l_cur into l_ID, l_tableName;
EXIT WHEN l_cur%notfound;
-- update missing VerbID in DocumentDocMapping table
UPDATE &HKAPPDB_Schema_Name..IndexedDocument
SET VerbID = (SELECT t.VerbID
FROM (SELECT DocRef, VerbID, DateUpdated
FROM &HKAPPDB_Schema_Name..l_tableName dd - this is where the dynamic table name is used
WHERE dd.VerbID is not NULL))
WHERE HKColumnID = l_ID AND VerbID is NULL;
END loop;
end;
/When I try to execute this i get an error
ORA-00942: table or view does not exist
What am I doing wrong?
Regards,
Tobyredeye wrote:
I only started about 6 weeks ago, with no tutorials and learning it on the fly; Same here.. only my introduction was to a 12 node Oracle OPS cluster all those years ago.. and required a whole new mind set after using SQL-Server extensively. But it was fun. Still is. :-)
but thats what you get when a company throws you in at the deep end with a ridiculous time constraint to migrate a whole MSSQL DB.Migrating SQL-Server to Oracle is not a simple thing. A lot of best practices in SQL-Server are absolutely worse practices in Oracle - they are that different. Simple example is lock escalation - an issue in SQL-Server. In Oracle, the concept of a lock being escalated into a page lock simply does not exist.
In terms of getting the migration done as quickly and painlessly as possible I try to reuse all the logic as it appears in the MSSQL code - in this case it was using dynamic table names. I do not doubt that i am probably shooting myself in the foot in the long run.....As long as you do not splatter too much blood on us here.. not a problem :D
Seriously though - just keep in mind that what works in SQL-Server may not work as well (or even at all) in Oracle. So do not hesitate to refactor (from design to code to SQL) mercilessly when you think it is warranted. -
How to create bindings at runtime for Dynamic Tables ?
We have lot of Dynamic tables, In ADF, we need to try out the Dynamic EO, Dynamic VO, Dynamic DataControl and Dynamic binding for UI
Ex:
We need to load the data to the ADF table where database table name is dynamic, the columns in the tables are also dynamic. At runtime , we need to create VO, Dynamic binding and display to UI? We also should be able to add, delete,update records in the dynamic tables.
Does anyone done this before? Please shared your thoughts on thisHi,
for a table you can declaratively build a tree binding. Then you remove all the attribute items in the tree definition so that the number of attributes is dynamic. See: https://blogs.oracle.com/groundside/entry/towards_ultra_reusability_for_adf
Frank -
Structure of Dynamic Table in Function Module
Hi,
I'm trying to find a way to get as OUTPUT a dynamic Table from a Function Module.
I declared a table called T_DATA without a type.
And this table should have a dynamic table back.
The problem that I get the data back but, I only found a data without any field-elements.
The data is there but there's no structure, no table.
Is there any way that I can send the Data in a proper structure?Hi
Try using the following code
type-pools:slis.
data:it_fcat type lvc_t_fcat,
wa_fcat type lvc_s_fcat,
itab type ref to data.
data:it_fcat1 type slis_t_fieldcat_alv,
wa_fcat1 like line of it_fcat1.
data:cl_tab type ref to cl_alv_table_create,
wa_ref type ref to data.
field-symbols:<itab> type table,
<wa> type any,
<comp>.
create object cl_tab.
refresh:it_fcat.
wa_fcat-fieldname = 'NAME'.
wa_fcat-inttype = 'C'.
wa_fcat-intlen = '10'.
wa_fcat1-fieldname = 'NAME'.
wa_fcat1-inttype = 'C'.
wa_fcat1-intlen = '10'.
append wa_fcat to it_fcat.
append wa_fcat1 to it_fcat1.
wa_fcat-fieldname = 'NAME2'.
wa_fcat-datatype = 'CHAR10'.
wa_fcat1-fieldname = 'NAME2'.
wa_fcat1-datatype = 'CHAR10'.
append wa_fcat to it_fcat.
append wa_fcat1 to it_fcat1.
cl_alv_table_create=>create_dynamic_table(
exporting
I_STYLE_TABLE = I_STYLE_TABLE
it_fieldcatalog = it_fcat
I_LENGTH_IN_BYTE = I_LENGTH_IN_BYTE
importing
ep_table = itab
E_STYLE_FNAME = E_STYLE_FNAME
EXCEPTIONS
GENERATE_SUBPOOL_DIR_FULL = 1
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
assign itab->* to <itab>.
create data wa_ref like line of <itab>.
assign wa_ref->* to <wa>.
do.
assign component 'NAME' of structure <wa> to <comp>.
<comp> = 'AA'.
unassign <comp>.
assign component 'NAME2' of structure <wa> to <comp>.
<comp> = 'AB'.
insert <wa> into table <itab>.
exit.
enddo.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME = I_STRUCTURE_NAME
I_BACKGROUND_ID = ' '
I_GRID_TITLE = I_GRID_TITLE
I_GRID_SETTINGS = I_GRID_SETTINGS
IS_LAYOUT = IS_LAYOUT
it_fieldcat = it_fcat1
IT_EXCLUDING = IT_EXCLUDING
IT_SPECIAL_GROUPS = IT_SPECIAL_GROUPS
IT_SORT = IT_SORT
IT_FILTER = IT_FILTER
IS_SEL_HIDE = IS_SEL_HIDE
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT = IS_VARIANT
IT_EVENTS = IT_EVENTS
IT_EVENT_EXIT = IT_EVENT_EXIT
IS_PRINT = IS_PRINT
IS_REPREP_ID = IS_REPREP_ID
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS = IT_ALV_GRAPHICS
IT_HYPERLINK = IT_HYPERLINK
IT_ADD_FIELDCAT = IT_ADD_FIELDCAT
IT_EXCEPT_QINFO = IT_EXCEPT_QINFO
IR_SALV_FULLSCREEN_ADAPTER = IR_SALV_FULLSCREEN_ADAPTER
IMPORTING
E_EXIT_CAUSED_BY_CALLER = E_EXIT_CAUSED_BY_CALLER
ES_EXIT_CAUSED_BY_USER = ES_EXIT_CAUSED_BY_USER
tables
t_outtab = <itab>
EXCEPTIONS
PROGRAM_ERROR = 1
Regards -
WD4A Dynamic ALV Table with dynamic tables
Hi all,
first I want give you the information what I try to do.
I have an another WD4A application for administrative use in which I can assign certain tablefields to a certain user. You can say it's something like a customizing application.
In the next application (with my issues) I will display the tables for the user, but these tables are not the complete table.
I have a node in my context of the component controller which is bound to my ALV. I add during the runtime attributes to my node.
* .... coding ....declaration
* get the node
lr_node = wd_context->get_child_node( 'M_TABLE' ).
lr_node_info ?= lr_node->get_node_info( ).
* remove the attributes, if exists
lr_node_info->remove_dynamic_attributes( ).
* .... coding ....
* add attributes
LOOP AT l_t_m_table INTO l_s_m_table.
CLEAR ls_attribute.
* name of the attribute
MOVE l_s_m_table-NAME TO ls_attribute-NAME.
* DDIC type of the attribute
MOVE l_s_m_table-TYPE_NAME TO ls_attribute-TYPE_NAME.
* If the DDIC has a gen namespace like /B135/ replace the / with _
REPLACE ALL OCCURRENCES OF '/' IN ls_attribute-NAME WITH '_'.
* add the attribute
lr_node_info->add_attribute( EXPORTING
attribute_info = ls_attribute ).
ENDLOOP.
This coding works fine I get the columns in my ALV. Then I tried to fill my ALV table with data from a database table.
I created dynamicly an internal table with the following coding:
* Create dynamic table
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = l_t_FLDCAT
IMPORTING
EP_TABLE = l_t_NEW_M_TABLE.
* assign the table
ASSIGN l_t_NEW_M_TABLE->* TO <M_TABLE>.
* structure of table
CREATE DATA l_s_NEW_M_TABLE LIKE LINE OF <M_TABLE>.
ASSIGN l_s_NEW_M_TABLE->* TO <l_s_m_table>.
* get data from database
SELECT * FROM (l_m_table) INTO CORRESPONDING FIELDS OF TABLE <M_table> WHERE OBJVERS = 'A'.
With this coding I get the data from the database and only the required fields that means I have e.g. an itab with columns1, columns3, columns4 from the database.
I also added e.g. these columns (columns1, columns3, columns4 from the database) to the node as attribute. Now it should be possible to bind the table to the structure with this coding:
lr_comp_usage_m = wd_this->wd_cpuse_usage_alv_M_table( ).
* create component if not active
IF lr_comp_usage_m->has_active_component( ) IS INITIAL.
lr_comp_usage_m->create_component( ).
else.
* set data if node exists
l_ref_interfacecontroller = wd_this->wd_cpifc_usage_alv_M_table( ).
l_ref_interfacecontroller->set_data( lr_node ).
endif.
* bind table
lr_node->bind_table( <M_TABLE> ).
Now, I get an error, which is caused by the table binding.
In ST22 I get:
Short text
Line types of an internal table and a work area not compatible.
What happened?
Error in the ABAP Application Program
The current ABAP program "CL_WDR_CONTEXT_NODE_VAL=======CP" had to be
terminated because it has
come across a statement that unfortunately cannot be executed.
Error analysis
The statement
"INSERT wa INTO TABLE itab"
requires the lines of the internal table "TABLE" and the
work area " wa" to be compatible. Compatibility means
equivalence in the context of ABAP/4 type checking.
In this case, the condition is not satisfied because the internal table
"TABLE" has the line type "u" and the length 28, but the work area " wa"
has the type "C" and the length 2.
(If the work area " wa" is the header line of the internal
table "TABLE", the above inconsistency can arise if an internal
table t with the line type T1 is passed to a subroutine (FORM or
FUNCTION) as an actual parameter and the corresponding formal
parameter p is declared in the subroutine by "TABLES p STRUCTURE T2".
If then T1 and T2 are incompatible, the header line p
has the type T2 (specifed by STRUCTURE), but the internal
table p has the line type T1 (passed from the actual parameter)).
Source Code Extract
Line SourceCde
1 method if_wd_context_node~get_static_attributes_table .
2
3 field-symbols:
4 <element> like line of me->collection,
5 <static_attributes> type data,
6 <table> type index table.
7
8 * check whether elements are supllied or not
9 if me->elements_supplied = abap_false.
10 me->supply_elements( ).
11 endif.
12
13 clear table.
14
15 if me->table_ref is not initial.
16 assign me->table_ref->* to <table>.
17 table = <table>.
18 else.
19 loop at me->collection assigning <element> from from to to.
20 assign <element>->static_attributes->* to <static_attributes>.
error in line 21 insert <static_attributes> into table table.
22 endloop.
23 endif.
24
25 endmethod.
Any suggestions? Is it allowed to use bind_table() with a field symbol?
Another strange thing is that if I try the same with static itab and attributes during runtime it works, but only if the fields of the itab has the same name as the attributes, which means that I can not use itabs with fieldnames like /BI0/S_CUSTOMER and if I can not use them it's difficult to read data from database with SELECT * FROM ... INTO CORRESPONDING FIELDS OF TABLE itab.
Thanks in advance for your suggestions!
Best Regards,
MarcelHi Francois,
I solve it with the RTTI and the method
lr_node_info = lr_node_info->add_new_child_node(
name = 'Dynamic_TABLE'
IS_MANDATORY = ABAP_false
IS_MULTIPLE = ABAP_true
STATIC_ELEMENT_RTTI = lr_struct_descr
IS_STATIC = ABAP_false
I don't know why it doesn't work with adding attributes and binding the table after adding the attributes.
Anyway thanks for your help.
Best Regards,
Marcel -
hi,
I wrote one source code in RFC which gives output as dynamic table.
I want this dynamics table as output of RFC.
In RFC, Table parameter does not support TYPE u2018ANYu2019 to define Table as Dynamic.
During runtime, RFC Code supposed to identify and fill columns.
I want to provide output of this RFC to webservice.
Regards
Mohinder Singhhi
If your FM is RFC enabled you can't declare a generic type. that is the problem when you try to use the FM and try to pass a dynamic table name to get the data from the remote system. or you can check
Check these FM 's: RFC_READ_TABLE
RFC_GET_TABLE_ENTRIES
hope this will help
regards
Prashant -
Dynamic Table Selection function module
Dear Friends,
We have got critical requirement on Custom BAPI function module :
we have to pass one field name of table and table name : Eg (Matnr and MARC).
we have to get table contents w.r.t field name of table and table : Has to display MARC based on Matnr.
(It is something like we display table contents in SE11 and SE16, Our requirement is to get the data by giving random field name of table and table name ).
My View : Imports Tab of F.M of is static
Tables Tab of F.M could be dynamic....if so how to achieve or any other approach?
Note : Eg1 : Matnr and MARA (Input to F.M) -
> Get MARA contents (Table from F.M)
Eg2 : Matnr and MARC (Input to F.M) -
> Get MARC contents (Table from F.M)
Eg3 : Lifnr and LFA1 (Input to F.M) -
> Get LFA1 contents (Table from F.M)
Eg1 : Ebeln and EKKO (Input to F.M) -
> Get EKKO contents (Table from F.M)
Awaiting for positive and quick views.
Regards
SekharDear Sarcevic,
I have created zfunction module with imports and tables.
I'm able to manage import parameters as dynamical, but tables declaration gives fuzzy.
How do we make tables tab declaration in function module as dynamic? any other views?
Regards
Sekhar -
Dynamic table with field type table
Hi,
I´m using "cl_alv_table_create=>create_dynamic_table" to create a dynamic table for ALV Grid.
But...I need to use colors in ALV, then I need to declare a field type LVC_S_SCOL in dynamic table from "cl_alv_table_create=>create_dynamic_table".
How can I declare this in fieldcat?
The code:
Creating dynamic table
DATA: table_agrup TYPE REF TO data,
line_agrup TYPE REF TO data.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = t_fieldcat
IMPORTING
ep_table = table_agrup
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
ASSIGN table_agrup->* TO .
Printing ALV
CALL METHOD obj_grid->set_table_for_first_display
EXPORTING
is_variant = w_variant
i_save = 'A'
is_layout = w_layout
CHANGING
it_outtab =
it_fieldcatalog = t_fieldcat
it_sort = t_sort
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
Thanks.It is not possible with the METHOD cl_alv_table_create=>create_dynamic_table to include another table inside that newly generated table.
I have tried to do it with the code and I got the dynamic table created after at the end of the program.
In the code,
<DYN_TABLE> has same effect as your <table> variable
<DYN_WA> has same effect as your <HEADER>
REPORT ZTEST_NP_DYNAMIC.
DATA: DY_TABLE TYPE REF TO DATA,
DY_LINE TYPE REF TO DATA.
FIELD-SYMBOLS: <DYN_TABLE> TYPE STANDARD TABLE,
<DYN_WA>,
<DYN_FIELD>.
FIELD-SYMBOLS: <FS> TYPE ANY.
* To generate the Dyanmic table with the COLOR
DATA: LS_SOURCE TYPE STRING.
DATA: LT_SOURCE LIKE STANDARD TABLE OF LS_SOURCE WITH HEADER LINE.
DATA: L_NAME LIKE SY-REPID.
DATA: L_MESSAGE(240) TYPE C,
L_LINE TYPE I,
L_WORD(72) TYPE C.
DATA: L_FORM(30) TYPE C VALUE 'TABLE_CREATE'.
LT_SOURCE = 'REPORT ZTEST_SUBROUTINE_POOL.'.
APPEND LT_SOURCE.
LT_SOURCE = 'FORM TABLE_CREATE USING I_FS TYPE ANY.'.
APPEND LT_SOURCE.
LT_SOURCE = 'DATA: BEGIN OF LT_GENTAB OCCURS 0.'.
APPEND LT_SOURCE.
LT_SOURCE = 'DATA: BUKRS TYPE BUKRS. '.
APPEND LT_SOURCE.
LT_SOURCE = 'DATA: BKTXT TYPE BKTXT. '.
APPEND LT_SOURCE.
* you can add your fields here.....
LT_SOURCE = 'DATA: COLOR TYPE lvc_t_scol. '.
APPEND LT_SOURCE.
LT_SOURCE = 'DATA: END OF LT_GENTAB.'.
APPEND LT_SOURCE.
LT_SOURCE = 'DATA: POINTER TYPE REF TO DATA.'.
APPEND LT_SOURCE.
LT_SOURCE = 'CREATE DATA POINTER LIKE STANDARD TABLE OF LT_GENTAB.'.
APPEND LT_SOURCE.
LT_SOURCE = 'I_FS = POINTER.'.
APPEND LT_SOURCE.
LT_SOURCE = 'ENDFORM. '.
APPEND LT_SOURCE.
L_NAME = 'ZTEST_SUBROUTINE_POOL'.
CATCH SYSTEM-EXCEPTIONS GENERATE_SUBPOOL_DIR_FULL = 9.
GENERATE SUBROUTINE POOL LT_SOURCE NAME L_NAME
MESSAGE L_MESSAGE LINE L_LINE WORD L_WORD. "#EC CI_GENERATE
ENDCATCH.
IF NOT L_MESSAGE IS INITIAL.
MESSAGE E000(0K) WITH L_MESSAGE L_LINE L_WORD.
ENDIF.
ASSIGN DY_TABLE TO <FS>.
PERFORM (L_FORM) IN PROGRAM (L_NAME) USING <FS>.
ASSIGN DY_TABLE->* TO <DYN_TABLE>.
* Create dynamic work area and assign to FS
CREATE DATA DY_LINE LIKE LINE OF <DYN_TABLE>.
ASSIGN DY_LINE->* TO <DYN_WA>.
Write: 'bye'.
Regards,
Naimesh Patel -
How to create a structure which can hold a dynamic table as a field in DDIC
Hi ,
I am designing a solution for a problem and have a unique requirement. I need to create a structure which can hold a field where dynamic table data can be stored. Let me illustrate with an example :
My structure ( say Z_output_struc ) will have the fields
Table_name Table_Data
My function module will have a table type of the above structure, so in effect ,my output can have multiple table names and related to each of them, there will be table data of that table name. The issue is how do I configure this in DDIC ?
I tried creating table_data as "Type ref to Data" but was stuck inside the func module when I tried to transfer data to this.
Any pointers as to how to think about this differently ?
Best Regards,
GirishHi Girish,
you start directly from the ref to data. You assign it to a field symbol and cast this to the type of the destination of your select. So you can directly add the reference to the cache:
I hope this example helps a bit (I took a form instead of a function module as it is easier to add here and used an hr table as kna1 is empty on my test system):
REPORT z_rwe_99_dyn_tab_cache.
* type definition
TYPES:
BEGIN OF _s_cache,
table TYPE tabname16,
cache TYPE REF TO data,
END OF _s_cache,
_t_cache TYPE STANDARD TABLE OF _s_cache.
* data declaration
DATA:
lv_table TYPE tabname16,
lv_condition TYPE string,
lt_cache TYPE _t_cache.
* define table and condition
lv_table = 'HRP1000'.
lv_condition = 'plvar = ''01'' and otype = ''S'' and objid = ''50000016'''.
* get the result of a single table into the cache
PERFORM get_dyn_table USING
lv_table
lv_condition
CHANGING
lt_cache.
* form to read a single table
FORM get_dyn_table USING
iv_table TYPE tabname16
iv_condition TYPE string
CHANGING
ct_cache TYPE _t_cache.
FIELD-SYMBOLS:
<lt_table> TYPE ANY TABLE.
DATA:
ls_cache TYPE _s_cache,
lr_data TYPE REF TO data.
CREATE DATA lr_data TYPE STANDARD TABLE OF (iv_table).
ASSIGN lr_data->* TO <lt_table>.
SELECT * FROM (iv_table) INTO TABLE <lt_table>
WHERE
(iv_condition).
ls_cache-table = lv_table.
ls_cache-cache = lr_data.
APPEND ls_cache TO ct_cache.
ENDFORM. "get_dyn_table
If you have more questions just give another post.
Best Regards
Roman -
How to pass Stages Guid dynamically in declarative workflow
hello,
How to pass Stages Guid dynamically in declarative workflow.
Example For List we used to pass guid like this
System.Guid.Parse("{$ListId:Lists/Testlist;}")
help me out to pass stage guid...
any help would be appreciated!!!!
Thanks regards, Vignesh.You need to make use of command line arguments. You can go through this link for example.
http://www.freeos.com/guides/lsst/ch02sec14.html
In your shell script(say test.sh) you can have
exp fas/xxxxxx@fasbd001 file=audit_grn_28aug.dmp tables=audit_grn query=\"where org_grp_i=$1 \"$1 indicates it accepts the first argument from command line. if you want to pass 19, add that next to the script you're executing.
From command line you can call this shell script say test.sh 19
Maybe you are looking for
-
This morning I went to go into Firefox, a message came up stating it was updating. After the update, Firefox didn't open, so I clicked on the icon and got this message. C:\Program Files (x86) Mozilla Fire\firefox.exe. The application has failed to st
-
Issue in seperating lines of ITAB and placing into SF secondary windows
Great abapers, My itab is having 6 lines item (for ex ) it may 'n' no of line items. In smartforms for 1 page max allowed secondary window is 2.so first 2 lines are paced in first page , next 2 lines are place in second page ,last 2 will be in 3 page
-
My Macbook Pro 15-inch with retina display crashes sometimes when connected to an external monitor
My almost-new Macbook Pro 15-inch with retina display goes black and shuts down sometimes when connected to my external monitor. (The first time it did this was when connected to a projector.) They have replaced the motherboard but it still happens s
-
Different custom colors for a WPF line plot
Dear Sir, I am trying to create a WPF graph with different colors for different points of time , example Black 0-10,red 11-20, green 21-30... I saw the nifty video and download the range masking cursor but got stuck. Thank you George MAsiello
-
How-To create a customized Solaris 10 DVD for Sparc with GRUB
I am currently using Solaris 10 U6 x86 custom jumpstart from DVD. This boot mechanism has always been Grub. I know that Solaris 10 U8 Sparc boot mechanism has been changed to Grub as well. I have referenced an excellent Blueprint on creating customiz