Array in abap

hi,
is there a concept as array which you find in C,C++.
say for example, i want to store a string in an array format, str1(10) and i want to read the 5th array record that is str1(5) in ABAP,
thank you.
Aditya Varrier .

Hi Aditya
In ABAP there is not an exactly corresponding definition for arrays in other languages. The closest one is the internal table concept which Rich explained.
Internal table records are read with "LOOP AT...ENDLOOP." and "READ TABLE" statements which retrieves the whole record. With the record you have, you address the field name to get the stored value there, e.g. <i>itab-field_name</i>. That is; an array-like structure can be constructed in ABAP with an internal table having one columns.
For your palindrome example, we may switch to a different concept that ABAP provides utilities to handle string operations as Thomas demonstrated. Mainly, the position and offset additions are used.
e.g.
var1 = 'Aditya'
var1+1(2) = 'di'
var1(2) = 'Ad'
var1+3 = 'tya'
var1(4) = 'Adit'
So, please get some further from the array understanding of other languages and try to be familiar to the intarnal table view concept which you can easily implement in your ABAP programs.
Regards
*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

Similar Messages

  • How to define an array in ABAP

    Hi experts,
       Can we define an array in ABAP. if yes then How. plz help.
    Regards.
    Vaibhav Tiwari.

    Hi,
      There are no array concept in abap, instead of array there are internal table and field strings in abap.
    Ex.
    data : begin of itab occurs 10,
              matnr like mara-matnr
              mbrsh like mara-mbrsh,
              end of itab.
    data : begin of itab,
              matnr like mara-matnr
              mbrsh like mara-mbrsh,
              end of itab.
    Regards,
    Prashant

  • Array Processing in ABAP

    Hi all,
    I am a total newbie in ABAP.
    I need to process an array in ABAP.
    If it was in .NET C#, it will be like this:
    String strArr = new String[5] { "A", "B", "C", "D", "E" };
    int index = -1;
    for (int i=0; i<strArr.length; i++)
       if (myData.equals(strArr<i>))
            index = i;
            break;
    Can someone please convert the above code into ABAP?
    Urgent. Please help. <REMOVED BY MODERATOR>
    THank you.
    Edited by: Alvaro Tejada Galindo on Feb 22, 2008 5:37 PM

    Hi,
    There is no concept of arrays in ABAP, we use internal tables to hold application data. U can use access internal tables with index.
    Read table itab index l_index this is same as u do in case of arrrays a(l_index)
    Instead use an Internal table to
    populate the values and read them ..
    say your Internal table has a field F1 ..
    itab-f1 = 10.
    append itab.
    clear itab.
    itab-f1 = 20.
    append itab.
    clear itab.
    itab-f1 = 30.
    append itab.
    clear itab.
    Now internal table has 3 values ...
    use loop ... endloop to get the values ..
    loop at itab.
    write :/ itab-f1.
    endloop.
    Also you can do this way:
    IT IS POSSIBLE TO DECLARE THE ONE -DIMENSIONAL ARRAY IN ABAP BY USING INTERNAL TABLES.
    EX.)
    DATA: BEGIN OF IT1 OCCURS 10,
    VAR1 TYPE I,
    END OF IT1.
    IT1-VAR1 = 10.
    APPEND IT1.
    IT1-VAR1 = 20.
    APPEND IT1.
    IT1-VAR1 = 30.
    APPEND IT1.
    LOOP AT IT1.
    WRITE:/ IT1-VAR1 COLOR 5.
    END LOOP.
    <REMOVED BY MODERATOR>
    Cheers,
    Chandra Sekhar.
    Edited by: Alvaro Tejada Galindo on Feb 22, 2008 5:38 PM

  • ABAP Server Proxy: Mapping XSD to ABAP

    Dear all,
    has anyone faces the follwoing problem?
    I make a  conversion of a field (length is 2) during a file content conversion of a sender file adapter. However in most cases the field is filled with only one character and a subsequent blank. The conversion cuts the space, so in my taret XML structure I will have a field of length 1 or 2, right?
    When I generate the corresponding inbound proxy (i have file to proxy scenario), the xml field of length 1-2 has to be mapped to a char array in ABAP. How long will this array be? I suppose it will have length 2. But what happens in the case that the subsequent blank has been **** during the conversion? Will the ABAP field be filled up was a blank again? (leading or subsequent?)
    Isn't it better in that case not to make any restrictions to the length of the string in the xml structure? In that case, i think in ABAP these field will have to be interpreted as dynamic string, right?
    What would you prefer?
    Kind regards
    Florian

    Hi Mahi,
    in that case i could also just prevent xi from trimming using that parametter:
    NameA.fieldContentFormatting
    ○       Enter trim to remove all the leading and subsequent blanks for a value found. This is the default.
    ○       Specify nothing to ensure that the value remains unaltered.
    However, id like to trimm those blanks, but i want to know how i can send them to the proxy without getting "new blanks"

  • How to call method excel subtotal in ABAP program

    I'm trying to call excel method subtotal, but i get an error (sy-subrc <> 0). How to correctly call this method? One of the parameters is an array. I've tried to use an internal table as the array, but ABAP syntax checker shows error.

    Hi Vytautas,
    The best way is to start recording a Macro(Tools->Macro->Record New Macro), and then do the operations (like entering data into cells, summing up, calculations,etc...)
    once you are done, display the macro and you will find all the needful information regarding what metohds are to be called and how...
    Regards,
    Raj

  • Loopping in an String array

    How to loop in a String array in ABAP?

    when you talk about loop....a loop is meant to traverse multiple entries....for example in a table...we can loop on rows...
    what exactly do you mean by looping on a string array (As such there are no arrays in ABAP).
    if you have multiple strings, you can put each string in an internal table and then loop through this internal table using the LOOP AT....ENDLOOP statements.
    in case of a single string, you can traverse it using offsets
    eg : STR+0(10) ---> which means start from position 0 and read 10 characters.
    please clarify a bit more on your requirement.

  • Querying using Native SQL

    Hi Pals,
    I have a requirement which I would like to brief.
    I have an internal table with columns FIELD1 and FIELD2. For all the values in FIELD1 I have to query a table MSI(which does not form a part of the R/3 framework) through Native SQL statement and get the corresponding values for FIELD2.
    Could anybody suggest how I must proceed writing my statements between EXEC and ENDEXEC.
    Do I have to query the database table for each entry in my internal table or is it possible to use for all entries in my SQL statemnt.
    Your inputs would be highly appreciated.
    Thank You in advance.
    Regards,
    Gayathri N.

    Hai Gayathri
    check this document
    EXEC SQL.
    Addition
    ... PERFORMING form
    Effect
    Executes the Native SQL command enclosed by the statements EXEC SQL and ENDEXEC . In contrast to Open SQL , addressed database tables do not have to be known to the ABAP/4 Dictionary and the ABAP/4 program does not have to contain appropriate TABLES statements.
    Example
    Create the table AVERI_CLNT :
    EXEC SQL.
      CREATE TABLE AVERI_CLNT (
             CLIENT   CHAR(3)  NOT NULL,
             ARG1     CHAR(3)  NOT NULL,
             ARG2     CHAR(3)  NOT NULL,
             FUNCTION CHAR(10) NOT NULL,
             PRIMARY KEY (CLIENT, ARG1, ARG2)
    ENDEXEC.
    With Native SQL commands, passing data between an ABAP/4 program and the database is achieved using host variables . A host variable is an ABAP/4 variable prefixed by a "*" in the Native SQL statement.
    Example
    Display a section of the table AVERI_CLNT :
    DATA: F1(3), F2(3), F3(3).
    F3 = ' 1 '
    EXEC SQL.
      SELECT CLIENT, ARG1 INTO :F1, :F2 FROM AVERI_CLNT
             WHERE ARG2 = :F3
    ENDEXEC.
    WRITE: / F1, F2.
    To simplify the spelling of INTO lists in the SELECT command, you can specify a single structure as the target area as in Open SQL .
    Example
    Display a section of the table AVERI_CLNT :
    DATA: BEGIN OF WA,
            CLIENT(3), ARG1(3), ARG2(3),
          END OF WA.
    DATA  F3(3).
    F3 = ' 1 '
    EXEC SQL.
      SELECT CLIENT, ARG1 INTO :WA FROM AVERI_CLNT
             WHERE ARG2 = :F3
    ENDEXEC.
    WRITE: / WA-CLIENT, WA-ARG1.
    Notes
    In contrast to Open SQL , a client field in Native SQL is a field like any other and must be specified explicitly in calls.
    Authorization checks cannot be properly realized in EXEC SQL . You should perform these in the program.
    When you start the R/3 System, a CONNECT to the current database is executed automatically. An explicit CONNECT is unnecessary.
    A Native SQL command can (but does not have to) end with a ";". Under no circumstances should it end with a ".".
    Some database systems allow upper and lower case in table names and field names. If you want to take advantage of this, you must ensure that the spelling of names is correct. To enable entry of lower case letters in names in the ABAP/4 editor, you must set the attribute for upper/lower case in the report.
    Since there are no arrays in ABAP/4 , array operations are not possible in Native SQL . If the result of a SELECT command is a table, you can read this table line by line either with the Native SQL command FETCH or with the addition ... PERFORMING form .
    Unlike in ABAP/4 programs, the character " in a Native SQL statement does not introduce a comment until the end of the editor line.
    Addition
    ... PERFORMING form
    Effect
    If the result of a SELECT command is a table, you can read this table line by line in a processing loop. The subroutine form is called once for each line. In this subroutine, you can leave the loop by using EXIT FROM SQL . If the result of the selection is a single record, the subroutine is called only once.
    Example
    Display a section of the table AVERI_CLNT :
    DATA: F1(3), F2(3), F3(3).
    F3 = ' 1 '
    EXEC SQL PERFORMING WRITE_AVERI_CLNT.
      SELECT CLIENT, ARG1 INTO :F1, :F2 FROM AVERI_CLNT
             WHERE ARG2 = :F3
    ENDEXEC.
    FORM WRITE_AVERI_CLNT.
      WRITE: / F1, F2.
    ENDFORM.
    Note
    This addition is allowed only with a SELECT command.
    Related SELECT , INSERT , UPDATE , MODIFY , DELETE , OPEN CURSOR , FETCH , CLOSE CURSOR, COMMIT WORK and ROLLBACK WORK .
    go to se38
    type 'EXEC' and put cursor on 'EXEC' press f1-function key
    then you get help for EXEC
    Thanks & regards
    Sreenivasulu P
    Message was edited by: Sreenivasulu Ponnadi

  • SAPRFC works great unless SAP is bounced

    'Everything is working fine unless SAP is taken off line. In which case the php.exe process cpu utilization jumps to 50% and is no longer listening for the RFC.
    Once SAP is back on line the php.exe process cpu time is still 50% and still no longer listening. Do I need an error trap, am I using something incorrectly, or is my code fundamentally flawed? Any help is appreciated.
    require_once( "api_tunnel.php" );
      $DEF_RFC_KWIKSHIP_API= array (
                      array (
                           "name"=>"MSGTOFS",
                           "type"=>"IMPORT",
                           "optional"=>"0",
                           "def"=> array (
                                array ("name"=>"","abap"=>"C","len"=>10000,"dec"=>0)
                      array (
                           "name"=>"MSGFROMFS",
                           "type"=>"EXPORT",
                           "optional"=>"0",
                           "def"=> array (
                                array ("name"=>"","abap"=>"C","len"=>10000,"dec"=>0)
    // Call script with: ./KWIKSHIP_rfc_connector.php -a KWIKSHIP_api -g hostname -x sapgw00 –t c:\
    $rfc = saprfc_server_accept ($argv);
    $fcl["KWIKSHIP_API"] = saprfc_function_define(0,"KWIKSHIP_API",$DEF_RFC_KWIKSHIP_API);
    // PHP server function
    while (true)
       $rc = saprfc_server_dispatch ($rfc, $fcl);
    function KWIKSHIP_api($fce) {
               $phpconnector_input_str = saprfc_server_import($fce,"MSGTOFS");
         $return_str = SendAPIMessage($phpconnector_input_str);
               saprfc_server_export ($fce,"MSGFROMFS",$return_str);
               return (true);
    //Attempt to run listener without ever closing the saprfc connection; Close RFC if necessary
    saprfc_close ($rfc);

    Hi,
    SAPRFC - works on - Windows Server 2003 (IIS x32) and on Apache WAMP -  PHP 5.2.8 - with - php_saprfc_528.dll.
    The crucial  thing is the c++ dll complilation. So you cannot use php_saprfc_530.dll for PHP 5.3.5 - it only works with
    PHP 5.3.0 and so on. Each php release needs its own c++ compilation for  the php_saprfc_xxx.dll.
    I already asked eduard.koucky at czech-tv.cz (the project leader) how to compile a php_saprfc_535.dll  together  with
    Visual Studio 2008 and saprfc_php5.sln?
    It seems to depend on the php dll build includes in the property sheets of the project in VS 2008:
    "..\Build\Php.Build\php-5.2.8";
    "..\Build\Php.Build\php-5.2.8\Zend";
    "..\Build\Php.Build\php-5.2.8\TSRM";
    "..\Build\Php.Build\php-5.2.8\main";
    "..\Build\Php.Build\php-5.2.8\win32";
    "C:\Program Files\Microsoft SDKs\Windows\v6.1\Include";
    ..\Build\RFCSDK.710.Win32\include;
    ..\Build\Php.Build\Win32\include
    You find existing versions of the php_saprfc_xxx.dlls here -> http://sourceforge.net/projects/saprfc/files/saprfc/ :
    4.3.0  -  4.3.2  -  4.3.8  -  4.3.10  -  4.4.0  -  4.4.1  -  4.4.9  -  5.0.0  -  5.0.3  -  5.0.4  -  5.1.1  -  5.2.8  -  5.3.0
    Best regards
    Axel Arnold Bangert - Herzogenrath 2011

  • How does execute PHP Script from SAP?

    I've already installed SAPRFC and run SAP Function from PHP successfully. But failed when tried execute PHP script from SAP (SM59). Anyone can help me for a clear instruction for this problem?
    Thanks

    Hi Max,
    here is the Source:
    [code]
    #!/usr/bin/php -q
    <?php
    // SAPRFC - Server example
    // PHP server function RFC_READ_REPORT
    // Require: CGI version PHP, RFC destination defined in SAP R/3 (SM59)
    // http://saprfc.sourceforge.net
    // Interface definiton for RFC_READ_REPORT
    // (generated by saprfc.php - option Generate PHP)
       $DEF_RFC_READ_REPORT = array (
                             array (
                                     "name"=>"SYSTEM",
                                     "type"=>"EXPORT",
                                     "optional"=>"0",
                                     "def"=> array (
                                             array ("name"=>"","abap"=>"C","len"=>8,"dec"=>0)
                             array (
                                     "name"=>"TRDIR",
                                     "type"=>"EXPORT",
                                     "optional"=>"0",
                                     "def"=> array (
                                             array ("name"=>"NAME","abap"=>"C","len"=>40,"dec"=>0),
                                             array ("name"=>"SQLX","abap"=>"C","len"=>1,"dec"=>0),
                                             array ("name"=>"EDTX","abap"=>"C","len"=>1,"dec"=>0),
                                             array ("name"=>"VARCL","abap"=>"C","len"=>1,"dec"=>0),
                                             array ("name"=>"DBAPL","abap"=>"C","len"=>1,"dec"=>0),
                                             array ("name"=>"DBNA","abap"=>"C","len"=>2,"dec"=>0),
                                             array ("name"=>"CLAS","abap"=>"C","len"=>4,"dec"=>0),
                                             array ("name"=>"TYPE","abap"=>"C","len"=>3,"dec"=>0),
                                             array ("name"=>"OCCURS","abap"=>"C","len"=>1,"dec"=>0),
                                             array ("name"=>"SUBC","abap"=>"C","len"=>1,"dec"=>0),
                                             array ("name"=>"APPL","abap"=>"C","len"=>1,"dec"=>0),
                                             array ("name"=>"SECU","abap"=>"C","len"=>8,"dec"=>0),
                                             array ("name"=>"CNAM","abap"=>"C","len"=>12,"dec"=>0),
                                             array ("name"=>"CDAT","abap"=>"D","len"=>8,"dec"=>0),
                                             array ("name"=>"UNAM","abap"=>"C","len"=>12,"dec"=>0),
                                             array ("name"=>"UDAT","abap"=>"D","len"=>8,"dec"=>0),
                                             array ("name"=>"VERN","abap"=>"C","len"=>6,"dec"=>0),
                                             array ("name"=>"LEVL","abap"=>"C","len"=>4,"dec"=>0),
                                             array ("name"=>"RSTAT","abap"=>"C","len"=>1,"dec"=>0),
                                             array ("name"=>"RMAND","abap"=>"C","len"=>3,"dec"=>0),
                                             array ("name"=>"RLOAD","abap"=>"C","len"=>1,"dec"=>0),
                                             array ("name"=>"FIXPT","abap"=>"C","len"=>1,"dec"=>0),
                                             array ("name"=>"SSET","abap"=>"C","len"=>1,"dec"=>0),
                                             array ("name"=>"SDATE","abap"=>"D","len"=>8,"dec"=>0),
                                             array ("name"=>"STIME","abap"=>"C","len"=>6,"dec"=>0),
                                             array ("name"=>"IDATE","abap"=>"D","len"=>8,"dec"=>0),
                                             array ("name"=>"ITIME","abap"=>"C","len"=>6,"dec"=>0),
                                             array ("name"=>"LDBNAME","abap"=>"C","len"=>20,"dec"=>0)
                             array (
                                     "name"=>"PROGRAM",
                                     "type"=>"IMPORT",
                                     "optional"=>"0",
                                     "def"=> array (
                                             array ("name"=>"","abap"=>"C","len"=>40,"dec"=>0)
                             array (
                                     "name"=>"QTAB",
                                     "type"=>"TABLE",
                                     "optional"=>"0",
                                     "def"=> array (
                                             array ("name"=>"LINE","abap"=>"C","len"=>72,"dec"=>0)
    // Create list of PHP server functions
       $GLOBAL_FCE_LIST[RFC_READ_REPORT] = saprfc_function_define(0,"RFC_READ_REPORT",$DEF_RFC_READ_REPORT);
    // PHP server function
       function RFC_READ_REPORT ($fce)
           $REPORT = saprfc_server_import ($fce,"PROGRAM");
           saprfc_table_init ($fce,"QTAB");
           $fd = fopen ($REPORT,"r");
           if (!$fd)
               return ("NOTFOUND");     // raise exception "NOTFOUND"
           while (!feof($fd))
               $LINE = fgets ($fd,73);
               saprfc_table_append ($fce,"QTAB",array("LINE"=>$LINE));
           fclose ($fd);
           saprfc_server_export ($fce,"SYSTEM","PHP");
           return (true);
    // Call script with: ./server.php -a phpgw -g hostname -x sapgw00
       $rfc = saprfc_server_accept ($argv);
    // Dispatch one function call
       $rc = saprfc_server_dispatch ($rfc,$GLOBAL_FCE_LIST);
       saprfc_close ($rfc);
    ?>
    [/code]
    Regards
    Gregor
    Message was edited by: Gregor Wolf

  • Is there arrays or FOR loops in ABAP?

    Hi everyone!
    Is there an array and FOR loops in ABAP similar to the C Language?
    If there is, please give example. _
    Thanks a lot!

    Hi,
    There is no array concept in ABAP but there are field-symbols which are same as pointers in C.As for the FOR loop there is no such command in SAP/ABAP but we do have the do..while and loop...endloop commands.There is also CASE statements and if..endif commands.
    Thanks,
    Sandeep.

  • Transforming ABAP internal table to JSON array (rather than object)

    Is there an easy way to do this using the standard CALL TRANSFORMATION?  Here's what I'm doing:
    "ABAP to JSON
       writer = cl_sxml_string_writer=>create( type = if_sxml=>co_xt_json ).
       CALL TRANSFORMATION id SOURCE ARRAY = lt_table
                              RESULT XML writer.
       lv_json = writer->get_output( ).
    Now this generates JSON with an object named ARRAY in the proper format with sub-objects... but I don't want an object named ARRAY, I just want an unnamed array.
    I searched through the documentation, the asJSON documentation seems to imply this should be possible, but doesn't specify any way to accomplish such a thing.  Leaving the name blank just generates an error.
    Tried a few transformation OPTIONS as well, but none of them seem to accomplish this.
    It's not a huge deal to use an object instead (although we're trying to squeeze every microsecond of performance out of this call), or even to just write my own darn transformation, but I guess I'm surprised SAP doesn't seem to support this functionality with CALL TRANSFORMATION.  Am I missing something?  Please tell me I'm missing something

    I honestly can't remember why I asked this question (I think I was just confused about why the object needed a name but that turned out to not really be a problem), but here's what I ended up doing, in case it's helpful:
    EDIT: I noticed above someone asked about uppercasing the JSON -- I also had to do this because the REST service I was calling required it.  You can see below I actually convert back to string to do this, though there may be a more elegant solution.
    *for call to cl_http_client=>create_by_destination
       constants:  lc_dest    TYPE rfcdest  value 'MILEMAKER'.
    *local structures for handling input/output
       DATA: ls_postal_dist type ZST_POSTAL_DIST,
             ls_postal_conv type ZST_POSTAL_DIST,
             lt_postal_conv type ZTT_POSTAL_DIST,
    *for call to cl_http_client=>create_by_destination
             lo_CLIENT type ref to IF_HTTP_CLIENT,
             ls_RANDMCNALLY_JSON type ZST_RANDMCNALLY_JSON,
             lt_RANDMCNALLY_JSON type table of ZST_RANDMCNALLY_JSON,
             lv_HTTP_REASON type string,
             lv_HTTP_CODE type i,
    *JSON conversion
             lo_writer TYPE REF TO cl_sxml_string_writer,
             lv_json_in TYPE xstring,
             lv_json_out TYPE xstring,
             lv_json_string type string,
             lo_conv  type ref to CL_ABAP_CONV_IN_CE,
             lo_conv2 type ref to CL_ABAP_CONV_OUT_CE,
    *return parameters and error handlers
             lo_cxroot   TYPE REF TO cx_root,
             lv_message type string,
             lv_PAR1 LIKE  SY-MSGV1,
             lv_PAR2 LIKE  SY-MSGV2,
             lv_PAR3 LIKE  SY-MSGV3,
             ls_return type bapiret2.  "return structure
    [snip]
    *set request parameters
           CALL METHOD lo_client->request->SET_CONTENT_TYPE('application/json').
           CALL METHOD lo_client->request->SET_METHOD('POST').
    *convert data to JSON
           lo_writer = cl_sxml_string_writer=>create( type = if_sxml=>co_xt_json ).
           CALL TRANSFORMATION id SOURCE routes = lt_RANDMCNALLY_JSON initial_components = 'suppress' RESULT XML lo_writer.
           lv_json_in = lo_writer->get_output( ).
    *attach data to body
           CALL METHOD lo_client->request->SET_DATA
             EXPORTING
               data = lv_json_in.
    *get JSON text in string format for testing
           CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE
             EXPORTING
               INPUT       = lv_json_in
               ENCODING    = 'UTF-8'
               REPLACEMENT = '?'
               IGNORE_CERR = ABAP_TRUE
             RECEIVING
               CONV        = lo_conv.
           CALL METHOD lo_conv->READ
             IMPORTING
               DATA = lv_json_string.
    *send HTTP POST call to RandMcNally webservice
           call method lo_client->send
    * exporting  timeout = lc_timeout
            exceptions http_communication_failure  = 1
            http_invalid_state = 2
            http_processing_failed = 3
            others = 4.
           if sy-subrc <> 0.
             CALL METHOD lo_client->get_last_error
               IMPORTING
                 message = lv_message.
             CONCATENATE 'HTTP POST:' lv_message into lv_message.
             move lv_message to ls_return-message.
             append ls_return to return.
           endif.
    *receive data back
           CALL METHOD lo_client->receive
             EXCEPTIONS
               http_communication_failure = 1
               http_invalid_state         = 2
               http_processing_failed     = 3
               others                     = 4.
    *pass errors back, if any
           if sy-subrc <> 0.
             clear ls_return.
             ls_return-type = 'E'.
             CALL METHOD lo_client->get_last_error
               IMPORTING
                 message = lv_message.
             move sy-subrc to lv_json_string.
             CONCATENATE 'RECEIVE DATA:' lv_json_string lv_message into ls_return-message SEPARATED BY space.
             append ls_return to return.
           endif.
    *get the data (a table in JSON format) from response object
           clear lv_json_out.
           lv_json_out = lo_client->response->GET_DATA( ).
    *get the status of the response
           CALL METHOD lo_client->response->GET_STATUS
             IMPORTING
               CODE   = lv_HTTP_CODE
               REASON = lv_HTTP_REASON.
    *if response status code not 200 (OK), return error and cease processing
           if lv_http_code <> '200'.
             clear ls_return.
             ls_return-type = 'E'.
             move lv_http_code to lv_json_string.
             CONCATENATE 'GET STATUS:' lv_json_string lv_HTTP_REASON into ls_return-message SEPARATED BY space.
             append ls_return to return.
           ENDIF.
         catch cx_root into lo_cxroot.
         cleanup.
           ls_return-message = lo_cxroot->get_text( ).
           append ls_return to return.
       endtry.
    *close channel
       CALL METHOD lo_client->close
         EXCEPTIONS
           http_invalid_state = 1
           others             = 2.
    *trying to process after error sometimes results in short dump because lv_json_out contains something other than JSON
       if ls_return is not initial.
         return.
       endif.
       if lv_json_out is not initial.
    *convert JSON to string and make it UPPERCASE so that SAP can do transformation
         CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE
           EXPORTING
             INPUT       = lv_json_out
             ENCODING    = 'UTF-8'
             REPLACEMENT = '?'
             IGNORE_CERR = ABAP_TRUE
           RECEIVING
             CONV        = lo_conv.
         CALL METHOD lo_conv->READ
           IMPORTING
             DATA = lv_json_string.
         TRANSLATE lv_json_string to UPPER CASE.
    *convert JSON back to xstring
         CALL METHOD CL_ABAP_CONV_OUT_CE=>CREATE
           EXPORTING
             ENCODING    = 'UTF-8'
             REPLACEMENT = '?'
             IGNORE_CERR = ABAP_TRUE
           RECEIVING
             CONV        = lo_conv2.
         lo_conv2->convert( EXPORTING data = lv_json_string
                      IMPORTING buffer = lv_json_out ).
    *convert our now UPPERCASE xstring to output table (JSON to ABAP)
         clear lt_randmcnally_json.
         lo_writer = cl_sxml_string_writer=>create( type = if_sxml=>co_xt_json ).
         CALL TRANSFORMATION id OPTIONS value_handling = 'accept_decimals_loss'
                                SOURCE XML lv_json_out
                                RESULT routes = lt_RANDMCNALLY_JSON.
    [snip]

  • The ABAP/4 Open SQL array insert results in duplicate database records

    Hi,
    Iam getting following error :
    The ABAP/4 Open SQL array insert results in duplicate database records.
    Error in ABAP application program.
    The current ABAP program "SAPLV60U" had to be terminated because one of the
    statements could not be executed.
    This is probably due to an error in the ABAP program.
    " Information on where terminated
    The termination occurred in the ABAP program "SAPLV60U" in "VBUK_BEARBEITEN".
    The main program was "SAPMSSY4 ".
    The termination occurred in line 503 of the source code of the (Include)
    program "LV60UF0V"
    of the source code of program "LV60UF0V" (when calling the editor 5030).
    Processing was terminated because the exception "CX_SY_OPEN_SQL_DB" occurred in
    the
    procedure "VBUK_BEARBEITEN" "(FORM)" but was not handled locally, not declared
    in the
    RAISING clause of the procedure.
    The procedure is in the program "SAPLV60U ". Its source code starts in line 469
    of the (Include) program "LV60UF0V "."
    Please assist how to proceed further ..
    Many thanks
    Mujeeb.

    Sorry, THe correct note is 402221.
    Description from the note
    << Please do not post SAP notes - they are copyrighed material >>
    Edited by: Rob Burbank on Feb 22, 2009 3:46 PM

  • ABAP/4 Open SQL array insert results in duplicate databaserecordsfor pk13

    Hi Experts, when I am working with pk13n tranaction iam getting an error message stating that update was terminated by user. when i am checking with st22 it gives the following message. please give the solution , iam sending the code as well.
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_SY_OPEN_SQL_DB', was not caught
    in
    procedure "SAVE_DATA" "(FORM)", nor was it propagated by a RAISING clause.
    Since the caller of the procedure could not have anticipated that the
    exception would occur, the current program is terminated.
    The reason for the exception is:
    If you use an ABAP/4 Open SQL array insert to insert a record in
    the database and that record already exists with the same key,
    this results in a termination.
    (With an ABAP/4 Open SQL single record insert in the same error
    situation, processing does not terminate, but SY-SUBRC is set to 4.) please find the below code please give the solution for this error message.
    1 *eject
    2 *----
    3 *   Verbuchen der Daten                                           *
    4 *----
    5 FORM SAVE_DATA.
    6
    7   DATA: lf_menge LIKE ekpo-menge VALUE 0,                   "717464
    8         lf_netwr LIKE ekpo-netwr VALUE 0.
    9
    10 * Einteilungen löschen --> Array Delete aus Tabelle DEKET
    11   DESCRIBE TABLE DEKET LINES SY-TFILL.
    12   IF SY-TFILL GT 0.
    13     DELETE EKET FROM TABLE DEKET.
    14     IF SY-SUBRC NE 0.
    15       MESSAGE A865.
    16     ENDIF.
    17     EKET_DELETE = EKET_DELETE + SY-DBCNT.
    18     REFRESH: DEKET.
    19     CLEAR  : DEKET.
    20   ENDIF.
    21
    22 * Einteilungen hinzufügen --> Array Insert aus Tabelle IEKET
    23   DESCRIBE TABLE IEKET LINES SY-TFILL.
    24   IF SY-TFILL GT 0.
    >>     INSERT EKET FROM TABLE IEKET.
    26     IF SY-SUBRC NE 0.
    27       MESSAGE A864.
    28     ENDIF.
    29     EKET_INSERT = EKET_INSERT + SY-DBCNT.
    30     REFRESH: IEKET.
    31     CLEAR  : IEKET.
    32   ENDIF.
    33
    34 * Check whether the qty in EKPO-MENGE is correct: note 717464
    35   SELECT SUM( menge ) FROM eket INTO lf_menge
    36                       WHERE ebeln = ekpo-ebeln
    37                       AND   ebelp = ekpo-ebelp.
    38   IF sy-subrc = 0 AND ekpo-menge <> lf_menge.
    39     IF ekpo-ktmng <> 0.
    40       refe1 = ekpo-zwert * lf_menge / ekpo-ktmng.
    41     ELSE.
    42       refe1 = ekpo-zwert * lf_menge / 1000.
    43     ENDIF.
    44     IF refe1 > maxwert.

    Hi,
    Well I don't know why you have duplicates, this is a functionnal issue. But you get the dump due the the message number 864 that triggers the abend... Changing the message type to 'E', 'S' or 'I' will prevent the dump but I guess this message has a good reason to be
    Kr,
    Manu.

  • The ABAP/4 Open SQL array insert results in duplicate Record in database

    Hi All,
    I am trying to transfer 4 plants from R/3 to APO. The IM contains only these 4 plants. However a queue gets generated in APO saying 'The ABAP/4 Open SQL array insert results in duplicate record in database'. I checked for table /SAPAPO/LOC, /SAPAPO/LOCMAP & /SAPAPO/LOCT for duplicate entry but the entry is not found.
    Can anybody guide me how to resolve this issue?
    Thanks in advance
    Sandeep Patil

    Hi Sandeep,
              Now try to delete ur location before activating the IM again.
    Use the program /SAPAPO/DELETE_LOCATIONS to delete locations.
    Note :
    1. Set the deletion flag (in /SAPAPO/LOC : Location -> Deletion Flag)
    2. Remove all the dependencies (like transportation lane, Model ........ )
    Check now and let me know.
    Regards,
    Siva.
    null

  • ABAP field symbols and PERL reference variables to unnamed arrays.

    Rob -
    Please do NOT delete this post even though it contains this link:
    ABAP field symbols and PERL reference variables to unnamed arrays.
    to a question I posted in the Scripting Languages forum.
    It's a question that should be of interest to ABAP programmers, and they may miss if they don't frequent the SL forum ...
    Thanks for your forbearance here (in advance, of course) ...
    Best
    djh
    Edited by: Rob Burbank on Jul 11, 2011 1:26 PM

    If interested, please reply in the original thread. We don't want multiple conversations at cross purposes do we?
    Rob

Maybe you are looking for