Function Modue with Dynamic Table as output parameter

Hi experts,
i have function (below) which reads "dynamically" data from table which is specify as input parameter, the data are "saved" in <ft>.
How can i return <ft> as output parameter of function module (table) ?
function
import parameter  - > IC_TABLE
source code
data :   lt_OPTIONS   type standard table of RFC_DB_OPT,
         lt_fields    type standard table of rfc_db_fld,
         lt_data      type standard table of tab512,
         la_rfcdata   type tab512,
         la_rfcfields type rfc_db_fld,
         lr_dref      type ref to data.
field-symbols: <ft>         type table.
field-symbols: <structure>  type any.
field-symbols: <field_to>   type any.
field-symbols: <field_from> type any.
CALL FUNCTION 'RFC_READ_TABLE'
  EXPORTING
    query_table                = IC_TABLE
  DELIMITER                  = ' '
  NO_DATA                    = ' '
  ROWSKIPS                   = 0
  ROWCOUNT                   = 0
  tables
    OPTIONS                    = lt_OPTIONS
    fields                     = lt_fields
    data                       = lt_data
EXCEPTIONS
   TABLE_NOT_AVAILABLE        = 1
   TABLE_WITHOUT_DATA         = 2
   OPTION_NOT_VALID           = 3
   FIELD_NOT_VALID            = 4
   NOT_AUTHORIZED             = 5
   DATA_BUFFER_EXCEEDED       = 6
   OTHERS                     = 7.
  create data lr_dref type table of (ic_table).
  assign lr_dref->* to <ft>.
Fill data from OLTP table into ct_table.
  assign local copy of initial line of <ft> to <structure>.
  loop at lt_data into la_rfcdata.
    loop at lt_fields into la_rfcfields.
      assign component sy-tabix of structure <structure> to <field_to>.
      if sy-subrc is initial.
        assign la_rfcdata+la_rfcfields-offset(la_rfcfields-length)
          to <field_from>.
        <field_to> = <field_from>.
      endif.
    endloop.
    append <structure> to <ft>.
  endloop.
Thanks in advance
Martin

Hi Martin,
parameters with generic types are not allowed. So TYPE ANY TABLE etc. will not work. As Alex alreads said, you could return a reference to your table.
Your parameter should be typed like:
re_table type ref to data.
At the end of your function module get a reference of your table into your parameter:
get reference of <ft> into re_table
After the call of your function module you can now handle and work with your table as wished:
* Declaration
data: re_table type ref to data.
field-symbols: <my_table> type standard table.
* Assign reference to fieldsymbol
assign re_table->* to <my_table>
if sy-subrc NE 0.
" Error: Could not assign reference
endif.
Best regards,
Fabian

Similar Messages

  • How to call a Stored Procedure with a REF CURSOR output parameter

    I am looking forward an example that call a stored function/procedure with a REF CURSOR output parameter and get the result.
    In other words, I have a stored function/procedure that execute a SELECT statement using the OCI library and then it could get the values of each column and each row.
    I put a code snippet, it have only the main thing to call a simple stored procedure and print the name of each column of the cursor, but I couldn´t to print out the values in the table that call the stored procedure.
    I understand that the next step, it is to call a OCIStmtFetch.
    How to associate the cursor with the OCIStmtFetch?
    If you need more information, only tell me.
    I am using ANSI C with HP-UX Operative System (C for HP-UX) and Oracle 10g.
    Regards.
    Antonio Garcia
    /* callOracleSP */
    #include <stdio.h>
    #include <string.h>
    #include <oci.h>
    #include <stdlib.h>
    char* pConnectChar ="server";
    char* pUsernameChar = "user";
    char* pPasswordChar = "passwd";
    char* sqlCharArray1 = "BEGIN SP_GETCITIES(:s, :c); END;";
    int retval;
    ub4 parmcnt=0;
    ub4 pos2=0;
    text *pcoln[20];
    ub4 namelen[20];
    char state_key[5];
    OCIStmt* pOciStatement;
    OCIStmt* pOciStatCursor;
    OCIError* pOciError;
    OCIEnv* pOciEnviron;
    OCIServer* pOciServer;
    OCISession* pOciSession;
    OCISvcCtx* pOciServiceContext;
    OCIBind* pOciBind[500];
    OCIParam* pOciParam;
    int main()
    retval = OCIEnvCreate(&pOciEnviron, OCI_DEFAULT, NULL, NULL, NULL, NULL,0,NULL);
    retval = OCIEnvInit(&pOciEnviron, OCI_DEFAULT, 0, NULL);
    retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciError, OCI_HTYPE_ERROR, 0, NULL);
    retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciServiceContext, OCI_HTYPE_SVCCTX, 0, NULL);
    retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciStatement, OCI_HTYPE_STMT, 0, NULL);
    retval = OCILogon(pOciEnviron,pOciError,&pOciServiceContext,(unsigned char *)pUsernameChar,
         strlen(pUsernameChar), (unsigned char *)pPasswordChar, strlen(pPasswordChar),
                   (unsigned char *)pConnectChar,strlen(pConnectChar));
    printf("OCILogon retval=%d\n",retval);
    retval = OCIStmtPrepare(pOciStatement, pOciError, (unsigned char *)sqlCharArray1,strlen(sqlCharArray1),
         OCI_NTV_SYNTAX, OCI_DEFAULT);
    printf("StmtPrepare retval=%d\n",retval);
    retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciStatCursor, OCI_HTYPE_STMT, 0, NULL);
    retval = OCIBindByPos(pOciStatement,&pOciBind[0], pOciError, (ub4) 1, (void *)&state_key,
         (sb4) sizeof(state_key), SQLT_STR, (void *) 0, (ub2 *) 0, (ub2 *)0,(ub4)0, (ub4 *)0, (ub4) OCI_DEFAULT);
    printf("BindByPos OCI_HTYPE_STMT retval=%d\n",retval);
    retval = OCIBindByPos(pOciStatement,&pOciBind[1], pOciError, (ub4) 2, (void *)&pOciStatCursor,
         (sb4) 0, SQLT_RSET, (void *) 0, (ub2 *) 0, (ub2 *)0,(ub4)0, (ub4 *)0, (ub4) OCI_DEFAULT);
    printf("BindByPos OCI_HTYPE_STMT retval=%d\n",retval);
    strcpy(state_key,"CA");
    retval = OCIStmtExecute(pOciServiceContext, pOciStatement, pOciError, (ub4)1, (ub4) 0,
         (OCISnapshot *)NULL, (OCISnapshot *)NULL, (ub4) OCI_DEFAULT);
    printf("StmtExecute retval=%d\n",retval);
    /* How to get the values of the cursor? */
    /* Get number of parameters of the Cursor */
    OCIAttrGet((void *) pOciStatCursor, (ub4)OCI_HTYPE_STMT, (void*) &parmcnt,(ub4 *) 0,
         (ub4)OCI_ATTR_PARAM_COUNT, pOciError);
    printf("\nNumber of parameters of the cursor = %d\n",parmcnt);
    for (int pos = 1; pos <= (int)parmcnt; pos++)
         OCIAttrGet((void *) pOciStatCursor, (ub4)OCI_HTYPE_STMT, (void*) &pos2,(ub4 *) 0,
              (ub4)OCI_ATTR_CURRENT_POSITION, pOciError);
         retval = OCIParamGet((void *)pOciStatCursor, (ub4)OCI_HTYPE_STMT, pOciError, (void **)&pOciParam,
              (ub4) pos );
         OCIAttrGet((void*) pOciParam, (ub4) OCI_DTYPE_PARAM,(void*) &pcoln[pos-1],(ub4 *) &namelen[pos-1],
              (ub4) OCI_ATTR_NAME,(OCIError *)pOciError );
    for (int i = 1; i <=(int)parmcnt; i++)
    printf("Column %i\tNAME = %.*s\n",i,namelen[i-1],pcoln[i-1]);
    return 0;
    This is the script that create the table, insert records and create the stored procedure
    CREATE TABLE CITIES (
         STATE_CODE     VARCHAR2(2) NULL,
         CITY_CODE      NUMBER(15,5) NULL,
         CITY_NAME      VARCHAR2(30) NULL
    INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES('CA', 30, 'SAN DIEGO')
    INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES('CA', 40, 'SACRAMENTO')
    INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES('FL', 10, 'MIAMI')
    INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES('FL', 20, 'ORLANDO')
    INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES('NY', 10, 'NEW YORK')
    INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES('NY', 20, 'ALBANY')
    INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES('CA', 10, 'LOS ANGELES')
    INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES('CA', 20, 'SAN FRANCISCO')
    CREATE OR REPLACE PACKAGE globalPkg AUTHID CURRENT_USER AS
    /* The following are T/SQL specific global variables. */
    TYPE RCT1 IS REF CURSOR;/*new weak cursor definition*/
    END globalPkg;
    CREATE OR REPLACE PROCEDURE SP_ADDCITY(
    P_STATE_CODE IN VARCHAR,
    P_CITY_CODE      IN NUMBER,
    P_CITY_NAME      IN VARCHAR2,
    P_RETURN IN OUT NUMBER)
    AS
    StoO_error INTEGER;
    StoO_selcnt INTEGER;
    StoO_rowcnt INTEGER;
    StoO_errmsg VARCHAR2(255);
         BEGIN
    StoO_rowcnt := 0;
    StoO_error := 0;
    StoO_selcnt := 0;
    P_RETURN := 0;
    INSERT INTO CITIES (STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES (P_STATE_CODE, P_CITY_CODE, P_CITY_NAME);
    StoO_rowcnt := SQL%ROWCOUNT;
    EXCEPTION
    WHEN TOO_MANY_ROWS THEN
    StoO_rowcnt := 2;
    WHEN OTHERS THEN
    StoO_rowcnt := 0;
    StoO_selcnt := 0;
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
              IF StoO_error != 0 THEN
    BEGIN
                   P_RETURN := 1;
         RETURN;
         END;
              END IF;
         END;
    CREATE OR REPLACE PROCEDURE SP_GETCITIES(
    STATE_KEY IN VARCHAR,
    RC1      IN OUT globalPkg.RCT1)
    AS
    StoO_error INTEGER;
    StoO_selcnt INTEGER;
    StoO_rowcnt INTEGER;
    StoO_errmsg VARCHAR2(255);
    BEGIN
    StoO_rowcnt := 0;
    StoO_error := 0;
    StoO_selcnt := 0;
    OPEN RC1 FOR
    SELECT STATE_CODE, CITY_CODE, CITY_NAME
    FROM CITIES
    WHERE STATE_CODE = STATE_KEY
    ORDER BY CITY_CODE;
    StoO_rowcnt := SQL%ROWCOUNT;
    EXCEPTION
    WHEN OTHERS THEN
    StoO_rowcnt := 0;
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
         END;
    /

    Hi Mark,
    Thanks for your recommendations.
    I change the code with OCIDefineByPos, one for each parameter from cursor and then use the OCIStmtFetch.
    I don´t receive a error when call OCIDefineByPos, but when I call OCIStmtFetch receive a -1 error number.
    What is wrong with the code?
    The script is the same.
    I need your help!
    Best Regards!
    Antonio Garcia (Mexico)
    This the new code:
    #include <stdio.h>
    #include <string.h>
    #include <oci.h>
    #include <stdlib.h>
      char*   pConnectChar ="ORAC617";
      char*   pUsernameChar = "C617_005_DBO_01";
      char*   pPasswordChar = "Tempora1";
      char*   sqlCharArray1 = "BEGIN SP_GETCITIES(:s, :c); END;";
      int     retval;
      ub4 parmcnt=0;
      ub4 pos2=0;
      sb2   *c_indp;
      text *pcoln[20], *name,*name2;
      ub4 namelen[20],len;
      ub2 type,size;
      char state_key[5];
      OCIDefine        *pdef;
      OCIBind          *p_bnd;
      ub1          **c_buf;
      OCIStmt*     pOciStatement;      /* Statement handle */
      OCIStmt*     pOciStatCursor;     /* Statement handle */   
      OCIError*    pOciError;          /* Error handle */
      OCIEnv*      pOciEnviron;        /* Environment handle */
      OCIServer*   pOciServer;         /* Server handle */  
      OCISession*  pOciSession;        /* Session handle */
      OCISvcCtx*   pOciServiceContext; /* Service Context handle */
      OCIBind*     pOciBind[500];      /* Bind handle */
      OCIParam*    pOciParam;          /* Param handle */
      int OCI_Fetch(OCIStmt *p_select,OCIError *p_err, int *piOcc)
      int iOcc, rc; 
      rc=OCIStmtFetch(p_select,p_err,1,OCI_FETCH_NEXT,OCI_DEFAULT);
      printf("rc fetch %i",rc);
      if(rc==0&&piOcc!=NULL){
           printf("entro al if");
        iOcc=*piOcc;
        *piOcc=iOcc+1;
      return rc;
    int main()
    int pos,i=0,rc;
      retval = OCIEnvCreate(&pOciEnviron, OCI_DEFAULT, NULL, NULL, NULL, NULL,0,NULL);
      printf("EnvCreate retval=%d\n", retval);
      retval = OCIEnvInit(&pOciEnviron, OCI_DEFAULT, 0, NULL);
      printf("EnvInit retval=%d\n",retval);
      retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciError, OCI_HTYPE_ERROR, 0, NULL);
      printf("HandleAlloc OCI_HTYPE_ERROR retval=%d\n",retval);
      retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciServiceContext, OCI_HTYPE_SVCCTX, 0, NULL);
      printf("HandleAlloc OCI_HTYPE_SVCCTX retval=%d\n",retval);
      retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciStatement, OCI_HTYPE_STMT, 0, NULL);
      printf("HandleAlloc OCI_HTYPE_STMT retval=%d\n",retval);
      retval = OCILogon(pOciEnviron,pOciError,&pOciServiceContext,(unsigned char *)pUsernameChar,
                  strlen(pUsernameChar), (unsigned char *)pPasswordChar, strlen(pPasswordChar),
                    (unsigned char *)pConnectChar,strlen(pConnectChar));
      printf("OCILogon retval=%d\n",retval);
      retval = OCIStmtPrepare(pOciStatement, pOciError, (unsigned char *)sqlCharArray1,strlen(sqlCharArray1),
                 OCI_NTV_SYNTAX, OCI_DEFAULT);
      printf("StmtPrepare retval=%d\n",retval);
      retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciStatCursor, OCI_HTYPE_STMT, 0, NULL);
      printf("HandleAlloc OCI_HTYPE_STMT retval=%d\n",retval);
      retval = OCIBindByPos(pOciStatement,&pOciBind[0], pOciError, (ub4) 1, (void *)&state_key,
                 (sb4) sizeof(state_key), SQLT_STR, (void *) 0, (ub2 *) 0, (ub2 *)0,(ub4)0, (ub4 *)0, (ub4) OCI_DEFAULT);
      printf("BindByPos OCI_HTYPE_STMT retval=%d\n",retval);
      retval = OCIBindByPos(pOciStatement,&pOciBind[1], pOciError, (ub4) 2, (void *)&pOciStatCursor,
                 (sb4) 0, SQLT_RSET, (void *) 0, (ub2 *) 0, (ub2 *)0,(ub4)0, (ub4 *)0, (ub4) OCI_DEFAULT);
      printf("BindByPos OCI_HTYPE_STMT retval=%d\n",retval);
      strcpy(state_key,"CA");
      retval = OCIStmtExecute(pOciServiceContext, pOciStatement, pOciError, (ub4)1, (ub4) 0,
                   (OCISnapshot *)NULL, (OCISnapshot *)NULL, (ub4) OCI_DEFAULT);
      printf("StmtExecute retval=%d\n",retval);
      c_buf=(ub1 **)calloc(sizeof(ub1 *),3);
      c_indp=(sb2 *)calloc(sizeof(sb2 *),3);
      // Get number of parameters of the Cursor
      OCIAttrGet((void *) pOciStatCursor, (ub4)OCI_HTYPE_STMT, (void*) &parmcnt,(ub4 *) 0,
                  (ub4)OCI_ATTR_PARAM_COUNT, pOciError);
      printf("\nNumber of parameters of the cursor = %d\n",parmcnt);
      for (pos = 1; pos <= (int)parmcnt; pos++)
           OCIAttrGet((void *) pOciStatCursor, (ub4)OCI_HTYPE_STMT, (void*) &pos2,(ub4 *) 0,
                (ub4)OCI_ATTR_CURRENT_POSITION, pOciError);
           retval = OCIParamGet((void *)pOciStatCursor, (ub4)OCI_HTYPE_STMT, pOciError, (void **)&pOciParam,(ub4) pos );
           // Get the column name
           OCIAttrGet((void*) pOciParam, (ub4) OCI_DTYPE_PARAM,(void*) &name,(ub4 *) &len, (ub4) OCI_ATTR_NAME,(OCIError *)pOciError );
            // Get the column datatype
           OCIAttrGet((void*) pOciParam, (ub4) OCI_DTYPE_PARAM,(void*) &type,(ub4 *)0,(ub4)OCI_ATTR_DATA_TYPE,(OCIError *)pOciError);      
            // Get the column size
           OCIAttrGet((void*) pOciParam, (ub4) OCI_DTYPE_PARAM,(void*) &size,(ub4 *)0,(ub4)OCI_ATTR_DATA_SIZE,(OCIError *)pOciError);
           printf("Column %i\tNAME = %.*s \ttype %d \tsize %d\n",pos,len,name,type,size);
           // OCIDefine ByPos, one for each parameter
           // c_buf store the STATE_CODE, CITY_CODE and CITY_NAME columns from the cursor
           rc=OCIDefineByPos(pOciStatCursor,&pdef,(OCIError *)pOciError,pos,c_buf[pos-1],size+1,(ub2)type,(dvoid *)c_indp[pos-1],(ub2 *)0,(ub2 *)0,OCI_DEFAULT);     
          printf("OCIDefineByPos retval=%d\n,rc);
      // call OCIStmtFetch. In the next line, I receive the error
      rc=OCIStmtFetch(pOciStatCursor,pOciError,1,OCI_FETCH_NEXT,OCI_DEFAULT);
      printf("rc fetch %i",rc);
      return 0;
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Dynamic table as output in Function Module

    Hi all,
    I am trying to output a dynamic table from a FM. I am a generating a dynamic internal table in the FM. Now i want to assign that internal table to a table parameter of the FM so that i can use that table in the calling program. can this be done?
    regards,
    hamza

    You may need to look into code of sap function module
    RFC_READ_TABLE

  • How to call a SP with dynamic columns and output results into a .csv file via SSIS

    hi Folks, I have a challenging question here. I've created a SP called dbo.ResultsWithDynamicColumns and take one parameter of CONVERT(DATE,GETDATE()), the uniqueness of this SP is that the result does not have fixed columns as it's based on sales from previous
    days. For example, Previous day, customers have purchased 20 products but today , 30 products have been purchased.
    Right now, on SSMS, I am able to execute this SP when supplying  a parameter.  What I want to achieve here is to automate this process and send the result as a .csv file and SFTP to a server. 
    SFTP part is kinda easy as I can call WinSCP with proper script to handle it.  How to export the result of a dynamic SP to a .CSV file? 
    I've tried
    EXEC xp_cmdshell ' BCP " EXEC xxxx.[dbo].[ResultsWithDynamicColumns ]  @dateFrom = ''2014-01-21''"   queryout  "c:\path\xxxx.dat" -T -c'
    SSMS gives the following error as Error = [Microsoft][SQL Server Native Client 10.0]BCP host-files must contain at least one column
    any ideas?
    thanks
    Hui
    --Currently using Reporting Service 2000; Visual Studio .NET 2003; Visual Source Safe SSIS 2008 SSAS 2008, SVN --

    Hey Jakub, thanks and I did see the #temp table issue in our 2008R2.  I finally figured it out in a different way... I manage to modify this dynamic SP to output results into
    a physical table. This table will be dropped and recreated everytime when SP gets executed... After that, I used a SSIS pkg to output this table
    to a file destination which is .csv.  
     The downside is that if this table structure ever gets changed, this SSIS pkg will fail or not fully reflecting the whole table. However, this won't happen often
    and I can live with that at this moment. 
    Thanks
    --Currently using Reporting Service 2000; Visual Studio .NET 2003; Visual Source Safe SSIS 2008 SSAS 2008, SVN --

  • 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,
    Marcel

    Hi 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

  • Itextsharp using livecycle form with dynamic table

    Hello all, after searching Google for the past two days and not able to find any relevant information, hence this post.
    Some background:
    1) Created a pdf form using Adobe Livecycle designer 9.
    2) It is a dynamic form with textboxes and a table configured to repeat rows dynamically.
    3) Testing form using xml data within designer works just fine.
    Requirement:
    Need to populate form dynamically using data from database.
    Solution:
    Found iTextSharp (free assembly) which assists with populating existing pdf form.
    Issue
    This assembly works without any issue when populating textfields (see sample code below). The problem I am facing is with the dynamic table where in I am not able to reference rows greater than 1. Since the pdf template contains a table with just one row referencing the first row using acrofield works.
    I was under impression since this is a dynamic table with repeat enabled, in asp.net if I referenced row2 onwards the table would grow automatically. Which I have come to realize is not going to be possible.
    So I am looking for ideas on how I can accomplish this. I wish this could have been a fixed row table then reference rows would have been easier. However in this situation the table has to be dynamic.
    Any ideas thoughts would be appreciated.
    Below is my sample code:
    PdfStamper ps = null;
    try {
    // read existing PDF document
    PdfReader r = new PdfReader(
    // optimize memory usage
    new RandomAccessFileOrArray(Request.MapPath("itext.pdf")), null
    ps = new PdfStamper(r, Response.OutputStream);
    // retrieve properties of PDF form w/AcroFields object
    AcroFields af = ps.AcroFields;
    // fill in PDF fields by parameter:
    // 1. field name
    // 2. text to insert
    af.SetField("txtCompany", "Company name");
    af.SetField("txtDateDepartLocation", "date depart location");
    af.SetField("txtDate","test date");
    af.SetField("txtServiceNumber", "Service number");
    af.SetField("Table2.Row1.Cell1", "1test");  this works
    //doesnt work!!!
    af.SetField("Table2.Row2.Cell1", "1test");
    af.SetField("Table2.Row3.Cell1", "1test");
    // make resultant PDF read-only for end-user
    ps.FormFlattening = true;
    // forget to close() PdfStamper, you end up with
    // a corrupted file!
    ps.Close();
    catch { }
    finally { if (ps != null) ps.Close(); }

    Hi FourEyes;
    Try using this.
    Select Col1, Col2, Col3
    into :P1_Field1, :P1_Field2, :P1_Field3
    from Your_Table
    Where (your conditions);

  • Page breaks with dynamic table

    Hi there!
    We've built a LiveCycle process in which we get data from an XML file and generate the PDF in LC Output.
    However, although the items are being correctly generated in the table, only the first 20 or so records are being included, generatin just one page.
    There are around 200 records in the XML - we just can't find how to set up the XDP in LC Designer so that we get a multipages PDF containing all 200 records instead of just 20.
    We are using a dynamic table with the following set up:
    Pagination: Following Previous
    In Binding tab, we checked Repeat Row for Each Data Item
    This table was inserted using the Insert Table option in main menu, using the wizard and it's inserted in a subform.
    All these setup options were applied to the table row element.
    Any ideas?
    Thank you!
    Marcos

    Hi Niall,
    Thank you for the input!
    However, there's something else we're missing here.
    After I tried your suggestion there were actually page breaks... we got 4 pages. However, only one of them had any content (the dynamic table with 30 records) and the other three were blank. The XML that populates the table includes 200 records.
    We're pulling our hair off here, trying to do this for days!...
    BR,
    Marcos

  • 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,
    Toby

    redeye 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.

  • Livecycle userform with dynamic table

    Hi Everyone,
    New to Livecycle Designer and was hoping this is possible - Can you have a PDF userform with a dynamic table below it?...
    Basically the user fills out a userform then clicks an ADD button - this populates a dynamic table below the userform then clears/resets the userform - as the records fill the table an EDIT button appears in the last column so that if the user makes an error with a record they could click the EDIT button, this would bring the record back into the userform fields so they could change the field(s) they made the error in then a SAVE button would replace the ADD button in this instance, clicking SAVE then changes the record and clears/resets the userform ready for more entries.
    At the bottom of the PDF there would be an EXPORT button which attaches the table as a csv or tab-delimited text file to an email message...
    If someone could point me in the right direction it would be appreciated - I have googled and searched the forums for an answer but they mostly relate to importing data into a dynamic table from a database or xml file... I was hoping to directly populate the table with the userform.
    I also have a PDF example which illustrates what I am trying to achieve... but seems you cannot attach to a post... I can email it if someone has a solution, but needs to see it visually.
    Cheers

    You don't know the names of your columns? hmm you do, because before you created dynamic table you had to create field catalog, so the structure and column names of newly (dynamically) created table will be the same like defined in the field catalog.
    The last loop also does not look good, in my opinion should be something like:
    LOOP AT lt_datatable +(my first table)+ ASSIGNING <ls_data4>.
        AT NEW pernr.
          APPEND initial line to <fs_1> assigning <fs_2>.
          <fs_2>-pernr = <ls_data4>-pernr.
        ENDAT.
        ASSIGN COMPONENT <ls_data4>-wage_type OF STRUCTURE <fs_2> TO <fs_5>.
        <fs_5> = <ls_data4>-amount.
    ENDLOOP.
    also keep in mind that number of calls of method cl_alv_table_create=>create_dynamic_table is limited to 36 (?) calls within one program session because it uses dynamic subroutine pool behind so you will have short dump if you will execute that 37 times.

  • Manipulate Layout on ALV Grid with dynamic table

    Dear all
    i'm generating a dynamic table depending of a date selection. That means that I show columns for weeks and the quantity of weeky migh change.
    Now the users wants to have a specific layout of the ALV grid with totals. When he saves the layout, only the weeks at this selection will show the next time he runs the programm with a larger selection.
    a) Is it possible to modify the layout during runtime by programming?
    b) Do you have any other ideas how to solve this problem?
    Thank you

    You don't know the names of your columns? hmm you do, because before you created dynamic table you had to create field catalog, so the structure and column names of newly (dynamically) created table will be the same like defined in the field catalog.
    The last loop also does not look good, in my opinion should be something like:
    LOOP AT lt_datatable +(my first table)+ ASSIGNING <ls_data4>.
        AT NEW pernr.
          APPEND initial line to <fs_1> assigning <fs_2>.
          <fs_2>-pernr = <ls_data4>-pernr.
        ENDAT.
        ASSIGN COMPONENT <ls_data4>-wage_type OF STRUCTURE <fs_2> TO <fs_5>.
        <fs_5> = <ls_data4>-amount.
    ENDLOOP.
    also keep in mind that number of calls of method cl_alv_table_create=>create_dynamic_table is limited to 36 (?) calls within one program session because it uses dynamic subroutine pool behind so you will have short dump if you will execute that 37 times.

  • SAP ME ADS Printing - Traveler with dynamic table

    Does any one have an example  traveler template that uses a dynamic table to display all the operations on the traveler? Ie one template that works for different routers.
    The problem we are having is due to the xml tags for each operation being different eg <operation0>, <operation1> etc which the dynamic table in Livecycle Designer doesn't seem to like.
    Thanks
    Kevin

    Hi Stuart,
    We are using ME15 SP03.
    We have already read that document cover to cover and we can print a traveler with SFC or Shop order header data etc. We can also print a fixed list of operations but what we want to do is have a single template that has a dynamic table that prints all the operations regardless of how many there are.
    Paragraph 6.11 of the document tells you that if you have multiple operations the binding should end with .Router_Step_ID0 , .Router_Step_ID1, Router_Step_ID2 etc etc
    This would mean that I would have to create a template for each different material that has a different number of router steps as you effectively hard code each step ID
    The first system I ever worked on (Visiprise 4.2) had the capability of using one template that automatically shrunk / expand based on the number of operations but I just cant see how to do it in LiveCycle Maybe I'm missing the obvious.
    Thanks
    Kevin
    PS. Great to see a fellow Scotsman on here

  • Issue with dynamic table which has RichCommandLink and RichSparkChart

    I’m running into an issue when I create a dynamic table with columns of type RichCommandLink and RichSparkChart.
    If my table has both of these types of columns, then the RichCommandLink column behaves like a NOP, meaning clicking on it does not cause the link to take effect and does not navigate to the designated page.
    If I remove the RichSparkChart column, then the RichCommandLink column behaves properly.
    Is there something I’m supposed to be aware of when creating these types of columns? Is there a known problem with RichSparkChart column, like some exception thrown which halts proper rendering of the rest of the columns?
    Thanks,
    Ania.

    Turned out that the problem was with ids which I was dynamically assigning. There was an overlap meaning two columns/elements got the same id. Not the manifestation or behavior I would expect as a result, but once I fixed that, having these two columns side by side works well.

  • How to export dynamic table to changing parameter of a method

    Hi ,
    There is one method in which i have created a dynamic table and populated the data now i want to send the same dynamic table which is in the form of field symbol to the changing parameters of the method
    with data

    Hi,
    Check these blogs,
    SAP Developer Network Blog: Dynamic Internal Tables and Structures - ABAP
    SAP Developer Network Blog: Dynamic Internal Table
    Regards,
    Alok Bansal
    Edited by: alok bansal on Dec 6, 2008 10:35 AM

  • Problem using DELETE ADJACENT DUPLICATES with dynamic table

    Hello All,
       In my program i have to delete duplicate records from dynamic table.
    I tried using  DELETE ADJACENT DUPLICATES FROM <DYN_TABLE> COMPARING <fieldname1> <fieldname2> but it fails in syntax check, then i tried like below:
      DATA string type string.
      string = '<fieldname1> <fieldname2>.........'.
      DELETE ADJACENT DUPLICATES FROM <DYN_TABLE> COMPARING (string).
    It also got failed at runtime.
    Please suggest how can i achieve this....
    Regards
    Munish Garg

    Hi,
    this code is worked truly.
    You can try this.
    Regards.
    DATA itab LIKE STANDARD TABLE OF mard.
    SELECT * FROM mard INTO TABLE itab UP TO 100 ROWS.
    * You define max number of the field that you need
    data : cmp01  TYPE string,
    cmp02 TYPE string,
    cmp03 TYPE string,
    cmp04 TYPE string,
    cmp05 TYPE string.
    * You fill the fields that you need, others is clear.
    cmp01  = 'MATNR'.
    cmp02 = 'WERKS'.
    CLEAR : cmp03,cmp04,cmp05.
    SORT itab BY (cmp01) (cmp02) (cmp03) (cmp04) (cmp05).
    DELETE ADJACENT DUPLICATES FROM itab COMPARING (cmp01) (cmp02) (cmp03)
    (cmp04) (cmp05).

  • Create Structure with dynamical Table-Type

    Hi experts,
    is there a possibility, to create a structure via SE11 and including there a field which referes to a dynamic table-type.
    So that I can append to this structure-field all different table-types?
    for example: ones I append MARA[] and ones AFKO[]
    Thx for help

    Hi Christian,
    There's not predefined generic type to do that, but you could create your own field type (deep structure) which would be able to keep table lines after transposition (90 degree flip) where in example it would have four columns: Table type, row id(index) field name, value. That way you could store ANY table row you need... This will not come cheap and will involve some work of course.
    You may want have a look at standard ABAP services RRTS and RTTI (see classes and structures used in attributes an parameters) - these are two services for handling data types and metadata related operations during runtime. You may want to use them for flipping your table entries to the tabular form and so on. You may also find some ideas there on how to compose your own data type for your purposes.
    Good luck!
    Marcin

Maybe you are looking for

  • Oracle vm 3.1.1 server pool file system corruption

    Hi I have a small lab environment composed by 2 Oracle VM Servers and SAN access. This morning somehow the OCFS2 Server Pool File System (the 12GB one) corrupted and the Server Pool seems dead. How can I recover from this error? I looked in the docum

  • Update Opportunity Totals button on Opprtunity Product Revenue line items

    Hello, In our application, the sales process is managed at the product revenue level. Each product line item goes through various stages and could be in the intiall state or get cancelled as well. I need to exclude these product revenue line items wh

  • Mdb dumps core (duh)

    While attempting to resolve a problem with mod_ssl vs. Sun Apache-1.3.27 (SUNWapch{d,r,u} with patch 113246-02), I decided to run apache trough mdb. # mdb /usr/apache/bin/httpd Loading modules: [ libc.so.1 ] :cmdb: fork1 detected: follow (p)arent or

  • PDF document protection

    When exporting a pages doc to PDF for emailing, can it be protected from editing by recipients -as in a newsletter?

  • 8.4RC mentions support for Fuji lens profiles - any details known?

    Curious if this is new support or if it's always been there and now ACR shows a message about it. I installed the ACR 8.4RC and loaded a RAW file from my X-T1. Looking at the Lens Corrections tab and the Profile sub-tab, there's now a message at the