Concatenate in loop

Hai,
As Iam using Loop in a Loop iam getting  time out dump .
in my internal table itab3 has unique objnr values.
for each objnr i have different status in itab_jcds.
each status column has diff status.
now i need to concatenate the status depending upon same objnr.
LOOP AT  ITAB3 INTO WA_ITAB3.
    RDX = SY-TABIX.
    LOOP AT ITAB_JCDS INTO WA_ITAB_JCDS WHERE OBJNR = WA_ITAB3-OBJNR.
     CONCATENATE WA_ITAB_JCDS-STATUS1 WA_ITAB3-STATUS1 INTO WA_ITAB3-STATUS1 SEPARATED BY SPACE.
      CONCATENATE WA_ITAB_JCDS-STATUS2 WA_ITAB3-STATUS2 INTO WA_ITAB3-STATUS2 SEPARATED BY SPACE.
      CONCATENATE WA_ITAB_JCDS-STATUS3 WA_ITAB3-STATUS3 INTO WA_ITAB3-STATUS3 SEPARATED BY SPACE.
      CONCATENATE WA_ITAB_JCDS-STATUS4 WA_ITAB3-STATUS4 INTO WA_ITAB3-STATUS4 SEPARATED BY SPACE.
    ENDLOOP.
    MODIFY ITAB3 FROM WA_ITAB3 INDEX RDX
                                        TRANSPORTING
                                        OBJNR
                                        STATUS1
                                        STATUS2
                                        STATUS3
                                        STATUS4.
  ENDLOOP.
example:
itab3
objnr
123
145
itab_jcds.
objnr                    stat1                    stat2                     stat3                     stat4
123                       nopr                      mav                     crtd                       rel
123                       CRTD                    mnav                    rel                        prt
123                       rel                          orsc                   txt                          crtd
now i req output as
itab3
objnr               stat1                    stat2                    stat3             stat4.
123           nopr crtd rel         mav mnav orsc        crtd rel txt      rel prt crtd
could u please help.

Hi,
Try this way..
SORT ITAB3 BY OBJNR.
SORT ITAB_JCDS BY OBJNR.
LOOP AT ITAB3 INTO WA_ITAB3.
RDX = SY-TABIX.
READ TABLE ITAB_JCDS INTO WA_ITAB_JCDS WITH KEY OBJNR = WA_ITAB3-OBJNR.
                                                                                BINARY SEARCH.
IF SY-SUBRC EQ 0.
LOOP AT ITAB_JCDS INTO WA_ITAB_JCDS FROM SY-TABIX.
IF WA_ITAB_JCDS-OBJNR NE WA_ITAB3-OBJNR.
EXIT.
ENDIF.
CONCATENATE WA_ITAB_JCDS-STATUS1 WA_ITAB3-STATUS1 INTO WA_ITAB3-STATUS1 SEPARATED BY SPACE.
CONCATENATE WA_ITAB_JCDS-STATUS2 WA_ITAB3-STATUS2 INTO WA_ITAB3-STATUS2 SEPARATED BY SPACE.
CONCATENATE WA_ITAB_JCDS-STATUS3 WA_ITAB3-STATUS3 INTO WA_ITAB3-STATUS3 SEPARATED BY SPACE.
CONCATENATE WA_ITAB_JCDS-STATUS4 WA_ITAB3-STATUS4 INTO WA_ITAB3-STATUS4 SEPARATED BY SPACE.
ENDLOOP.
MODIFY ITAB3 FROM WA_ITAB3 INDEX RDX
TRANSPORTING
OBJNR
STATUS1
STATUS2
STATUS3
STATUS4.
ENDIF.
ENDLOOP

Similar Messages

  • Concatenate Problem

    hi,
    thank you for supproting..
    Iam reading the sys status for order number.. One order number, we ve got no.of status. i need to keep all status textes in one field..
    As well as i need to write the status one which is start with I. so ive kept the condition stat = 'I*'. but its not working. can u plz tell me tht one also..
    for this ive wrote the code as below as ..
    Ordernumber:  Stat         " this is from Jest table
    R000400008    i008
    R000400008    i009
    R000400008    i010
    R000400008    i011
    Stat    Spar   txt04     " This is from tj02t table  " From here i need to Concatenate the all TXT04 INTO one feild for the one ordernumber.. and modify the itab..
    i008    E       PDV
    i009    E       DEV           "like R00040008        PDV DEV PEN REV       "Report should be get like
    i010    E       PEN
    i011    E       REV
    How to concatenate while looping..?
    **Calculation for system status.
    ITAB3[] = ITAB[].
    clear:wa.
    Loop at itab3 into wa.
       Select objnr stat from jest into corresponding fields of table lt_jest where objnr =  wa-objnr AND stat NE 'X'.
    *                                                  ( stat <> 'X' AND  stat = 'I*' ).
       Read table lt_jest into wa_jest with key objnr = wa-objnr transporting all fields.
       Select istat TXT04 from tj02t into corresponding fields of table lt_tj02t where istat = wa_jest-stat." and
    *                                                                             spras = 'EN'.
         Loop at lt_tj02t into wa_tj02t.
         lv_sttxt1 = wa_tj02t-txt04.
         CONCATENATE lv_sttxt1 ' ' into lv_sttxt SEPARATED BY space.      "Doubt here
         Endloop.
           Read table itab into wa2 with key objnr = wa-objnr.
           Move lv_sttxt To wa2-sttxt."STTXT
            lv_tabix = sy-tabix.
           Modify itab from wa2 index lv_tabix transporting sttxt.
    Endloop.
    Regards

    Do like
    Loop at itab3 into wa.
       Select objnr stat from jest into corresponding fields of table lt_jest where objnr =  wa-objnr AND stat LIKE 'I*'.
       CLEAR  lt_tj02t .
       Select istat TXT04 from tj02t into corresponding fields of table lt_tj02t for all entries in lt_jest  where istat = lt_jest -stat.
          CONCATENATE wa-objnr ' 'INTO  lv_sttxt1 separated by space.
         Loop at lt_tj02t into wa_tj02t.
         CONCATENATE lv_sttxt1  wa_tj02t-txt04  into lv_sttxt SEPARATED BY space.  
         Endloop.
            Move lv_sttxt To wa-sttxt.
           Modify TABLE itab from wa.
    Endloop.
    Edited by: Sachin Bidkar on Mar 18, 2010 11:07 AM

  • Dynamic creation of object names

    Dear all,
    I have chose a rather generic title for a rather special problem, since I believe the above is the root. I am trying to create a bunch of JButtons which should have a running number in their names, like: button1, button2, button3, etc. Naturally, I'd like to do this in a loop. But it seems like I can't just concatenate the loop index to the button name like this:
    for(int i = 0; i < x; i++)
          JButton myButton + i = new JButton("Text");
        }How else could I achieve this? Thanks a lot in advance for any hitns!
    Cheers,
    N.

    Sorry for checking back so late...got distracted.
    To clarify further: I want to populate a column in a JTable with the buttons. The table rows contain pairs of words for a simple vocabulary trainer. If the user clicks on the button, the respective row should be deleted. The table data is built in a loop that populates a 2-dimensional object array. So, the buttons need some sort of identifier associated with them, so that I can determine which row should be deleted.
    Cheers,
    N.

  • Another novice question...I opened a file used "Concatenate String" to write to file creating headers and so forth...a "While Loop" routine is m

    onitoring a voltage and storing it to the same file under the associated header...What I'm having problems doing is after the loop is completed I need to write the MIN\MAX values of the voltage that was monitored in the "While Loop" once it completes. I juBefore the loop the "Concatenate String" peforms the following... line1 col.1 in an excel file is (Tester then Line1 col.2 (the testers name appears) next is a end of line. Then Line2 col.1 is (DATE)header then col.2(TIME)header then col.3(throttle voltage output)header then col.4(MAX VOUT)header then col.5(MIN VOUT) as i said this is perform before the loop with no pr
    oblem. Next during the "While Loop" the actual information for the DATE,TIME,Throttle voltage output,are inserted into Line 3 under the associated header with no problem. What I need to do is wait until the "While Loop" has completed to then store the MAX/MIN, but I can't seem to get the information to end up under the associated header. What do I need to set/use to accomplish this task? Thanks I've attached an excel spread sheet to give an example of where I need the values to be stored.
    Attachments:
    test1.txt ‏1 KB

    onitoring a voltage and storing it to the same file under the associated header...What I'm having problems doing is after the loop is completed I need to write the MIN\MAX values of the voltage that was monitored in the "While Loop" once it completes. I juThis can become hard depending on how much data you will be writing. If you could wait and write the data all at one at the end of the while loop it becomes easier. The problem is that when you write a file it writes it in rows of data not columns. I will attach an example (LabVIEW 6.0) that demonstrates how to do this. It is a hard to describe in text. Basically I create the new columns of data and write empty strings to them on each iteration of the while loop except for the first iteration. The first iteration I write a Max? and Min? into the column information. After the while loop is completed I search the array for Max? and Min? and replace it with the appropriate min and max values.
    Attachments:
    append_column.vi ‏47 KB

  • I have used a 'for loop' to create an array of output data, however I want the each of the data sets from the array to be placed into a 1-D array. How do I concatenate the output of the for loop into a 1-D array?

    I am using this to create a data set that will be passed as an anolog output therefore it needs to have the correct array dimensions to go into the analog write vi.

    I'm updating my request... I've figured out how to do this by copying an example that uses a simple FOR loop (as seen in the attached current version of my VI). My question now becomes this: Is there a way to save the Y values corresponding to those X values into two more arrays? That is, just for argument's sake, let's say I took the first 100 elements from the X array, and found them to be positive. Then I would like to take the first 100 elements of the Y array and put them into a 'Y Values for X > 0' array. ...And likewise with the negative X values, they should have a separate array of corresponding 'Y values for X < 0' array.
    I can see that I should somehow save the indices of the positive X values from the large arrray wh
    en I sort them out, and use those indices to pick out the elements from the main Y array with the same indices.
    I just can't seem to set up the code necessary to do this. ...Can anyone help, please?
    Attachments:
    Poling_Data_Reader_5i.vi ‏79 KB
    30BLEND.txt ‏3 KB

  • SQL stored procedure Staging.GroomDwStagingData stuck in infinite loop, consuming excessive CPU

    Hello
    I'm hoping that someone here might be able to help or point me in the right direction. Apologies for the long post.
    Just to set the scene, I am a SQL Server DBA and have very limited experience with System Centre so please go easy on me.
    At the company I am currently working they are complaining about very poor performance when running reports (any).
    Quick look at the database server and CPU utilisation being a constant 90-95%, meant that you dont have to be Sherlock Holmes to realise there is a problem. The instance consuming the majority of the CPU is the instance hosting the datawarehouse and in particular
    a stored procedure in the DWStagingAndConfig database called Staging.GroomDwStagingData.
    This stored procedure executes continually for 2 hours performing 500,000,000 reads per execution before "timing out". It is then executed again for another 2 hours etc etc.
    After a bit of diagnosis it seems that the issue is either a bug or that there is something wrong with our data in that a stored procedure is stuck in an infinite loop
    System Center 2012 SP1 CU2 (5.0.7804.1300)
    Diagnosis details
    SQL connection details
    program name = SC DAL--GroomingWriteModule
    set quoted_identifier on
    set arithabort off
    set numeric_roundabort off
    set ansi_warnings on
    set ansi_padding on
    set ansi_nulls on
    set concat_null_yields_null on
    set cursor_close_on_commit off
    set implicit_transactions off
    set language us_english
    set dateformat mdy
    set datefirst 7
    set transaction isolation level read committed
    Store procedures executed
    1. dbo.p_GetDwStagingGroomingConfig (executes immediately)
    2. Staging.GroomDwStagingData (this is the procedure that executes in 2 hours before being cancelled)
    The 1st stored procedure seems to return a table with the "xml" / required parameters to execute Staging.GroomDwStagingData
    Sample xml below (cut right down)
    <Config>
    <Target>
    <ModuleName>TransformActivityDim</ModuleName>
    <WarehouseEntityName>ActivityDim</WarehouseEntityName>
    <RequiredWarehouseEntityName>MTV_System$WorkItem$Activity</RequiredWarehouseEntityName>
    <Watermark>2015-01-30T08:59:14.397</Watermark>
    </Target>
    <Target>
    <ModuleName>TransformActivityDim</ModuleName>
    <WarehouseEntityName>ActivityDim</WarehouseEntityName>
    <RequiredWarehouseEntityName>MTV_System$WorkItem$Activity</RequiredWarehouseEntityName>
    <ManagedTypeViewName>MTV_Microsoft$SystemCenter$Orchestrator$RunbookAutomationActivity</ManagedTypeViewName>
    <Watermark>2015-01-30T08:59:14.397</Watermark>
    </Target>
    </Config>
    If you look carefully you will see that the 1st <target> is missing the ManagedTypeViewName, which when "shredded" by the Staging.GroomDwStagingData returns the following result set
    Example
    DECLARE @Config xml
    DECLARE @GroomingCriteria NVARCHAR(MAX)
    SET @GroomingCriteria = '<Config><Target><ModuleName>TransformActivityDim</ModuleName><WarehouseEntityName>ActivityDim</WarehouseEntityName><RequiredWarehouseEntityName>MTV_System$WorkItem$Activity</RequiredWarehouseEntityName><Watermark>2015-01-30T08:59:14.397</Watermark></Target><Target><ModuleName>TransformActivityDim</ModuleName><WarehouseEntityName>ActivityDim</WarehouseEntityName><RequiredWarehouseEntityName>MTV_System$WorkItem$Activity</RequiredWarehouseEntityName><ManagedTypeViewName>MTV_Microsoft$SystemCenter$Orchestrator$RunbookAutomationActivity</ManagedTypeViewName><Watermark>2015-01-30T08:59:14.397</Watermark></Target></Config>'
    SET @Config = CONVERT(xml, @GroomingCriteria)
    SELECT
    ModuleName = p.value(N'child::ModuleName[1]', N'nvarchar(255)')
    ,WarehouseEntityName = p.value(N'child::WarehouseEntityName[1]', N'nvarchar(255)')
    ,RequiredWarehouseEntityName =p.value(N'child::RequiredWarehouseEntityName[1]', N'nvarchar(255)')
    ,ManagedTypeViewName = p.value(N'child::ManagedTypeViewName[1]', N'nvarchar(255)')
    ,Watermark = p.value(N'child::Watermark[1]', N'datetime')
    FROM @Config.nodes(N'/Config/*') Elem(p)
    /* RESULTS - NOTE THE NULL VALUE FOR ManagedTypeViewName
    ModuleName WarehouseEntityName RequiredWarehouseEntityName ManagedTypeViewName Watermark
    TransformActivityDim ActivityDim MTV_System$WorkItem$Activity NULL 2015-01-30 08:59:14.397
    TransformActivityDim ActivityDim MTV_System$WorkItem$Activity MTV_Microsoft$SystemCenter$Orchestrator$RunbookAutomationActivity 2015-01-30 08:59:14.397
    When the procedure enters the loop to build its dynamic SQL to delete relevant rows from the inbound schema tables it concatenates various options / variables into an executable string. However when adding a NULL value to a string the entire string becomes
    NULL which then gets executed.
    Whilst executing "EXEC(NULL)" would cause SQL to throw an error and be caught, executing the following doesnt
    DECLARE @null_string VARCHAR(100)
    SET @null_string = 'hello world ' + NULL
    EXEC(@null_string)
    SELECT @null_string
    So as it hasnt caused an error the next part of the procedure is to move to the next record and this is why its caught in an infinite loop
    DELETE @items WHERE ManagedTypeViewName = @View
    The value for the variable @View is the ManagedTypeViewName which is NULL, as ANSI_NULLS are set to ON in the connection and not overridded in the procedure then the above statement wont delete anything as it needs to handle NULL values differently (IS NULL),
    so we are now stuck in an infinite loop executing NULL for 2 hours until cancelled.
    I amended the stored procedure and added the following line before the loop statement which had the desired effect and "fixed" the performance issue for the time being
    DELETE @items WHERE ManagedTypeViewName IS NULL
    I also noticed that the following line in dbo.p_GetDwStagingGroomingConfig is commented out (no idea why as no notes in the procedure)
    --AND COALESCE(i.ManagedTypeViewName, j.RelationshipTypeViewName) IS NOT NULL
    There are obviously other ways to mitigate the dynamic SQL string being NULL, there's more than one way to skin a cat and thats not why I am asking this question, but what I am concerned about is that is there a reason that the xml / @GroomingCriteria is incomplete
    and / or that the procedures dont handle potential NULL values.
    I cant find any documentation, KBs, forum posts of anyone else having this issue which somewhat surprises me.
    Would be grateful of any help / advice that anyone can provide or if someone can look at their 2 stored procedures on a later version to see if it has already been fixed. Or is it simply that we have orphaned data, this is the bit that concerns most as I dont
    really want to be deleting / updating data when I have no idea what the knock on effect might be
    Many many thanks
    Andy

    First thing I would do is upgrade to 2012 R2 UR5. If you are running non-US dates you need the UR5 hotfix also.
    Rob Ford scsmnz.net
    Cireson www.cireson.com
    For a free SCSM 2012 Notify Analyst app click
    here

  • Loop at FM  Read_text

    Hi All,
    If I hardcode material number, without loop statement call function READ_TEXT gives subrc 0. If I pass it through internal table in a loop, it ends up with SUBRC 4.
    Moreover, this does not even enter into FM Read_text.
    can somebody help me with this.
    lOOP AT ITAB.
    ALL FUNCTION 'READ_TEXT'
      EXPORTING
        CLIENT                        =   SY-MANDT
        ID                                  =  'GRUN'
        LANGUAGE                =  'EN'
        NAME                          =  ITAB-MATNR
        NAME                          =  '000000000123456789'
        OBJECT                       =  'MATERIAL'
      ARCHIVE_HANDLE                = 0
      LOCAL_CAT                     = ' '
    IMPORTING
      HEADER                        =
      TABLES
        LINES                         =   IT_LINES
    EXCEPTIONS
         ID                            = 1
        LANGUAGE                      = 2
        NAME                          = 3
        NOT_FOUND                     = 4
        OBJECT                        = 5
        REFERENCE_CHECK               = 6
       WRONG_ACCESS_TO_ARCHIVE       = 7
        OTHERS                        = 8
    ENDLOOP.
    Thanks
    Sharat

    Try if this works.
    parameters p_matnr type matnr.
    data: temp_text type table of tline with header line,
          where_cond(20) type c.
    data : begin of text_id ,
             tdobject(10) value 'MVKE',
             tdname(70),
             tdid(4)      value '0001',
             tdspras   value 'D',
           end of text_id.
    start-of-selection.
    concatenate '%'
                p_matnr
           into where_cond.
    select single tdname
      from stxl
      into text_id-tdname
    where relid   = 'TX' and
           tdspras = 'E'  and
           tdname like where_cond.
    import tline = temp_text[]
      from database stxl(TX) id text_id.
    write: / sy-subrc.
    loop at temp_text.
      write : / temp_text-tdline.
    endloop.
    Thanks
    Mahesh

  • Doubt in loop

    Hi Gurus...........
    i have my code below ...problem is that when it goes for the first time if get the
    value but when it goes again in to the loop , first loop is getting exected
    the second and the third loop returns sy-subrc 4 thou it has value.....
    iam not able to find it out y????can you plzzz helppp???
    Code of loop
    ===============
    LOOP AT it_pos INTO wa_pos .
      READ TABLE it_kna1 INTO wa_kna1 WITH KEY kunnr = wa_pos-konto .
      IF sy-subrc = 0.
         wa_final-name1 = wa_kna1-name1.
         wa_final-xblnr = wa_pos-xblnr.
        read table it_t005u into wa_t005u with key  bland = wa_kna1-regio.
        If sy-subrc = 0.
          wa_final-bezei = wa_t005u-bezei.
         Endif.
      Endif.
    Loop at it_vbrp into wa_vbrp  where vbeln = wa_bkpf-vbeln.
        read table it_vbrk into wa_vbrk with key vbeln = wa_vbrp-vbeln.
        If sy-subrc = 0.
          wa_final-knumv = wa_vbrk-knumv.
        Endif.
        wa_final-arktx = wa_vbrp-arktx.
        wa_Final-fkimg = wa_vbrp-fkimg.
        move wa_final-arktx to wa_final-a.
        move wa_final-fkimg to wa_final-b.
        qty = wa_vbrp-fkimg.
        split qty at '.' into text2 text3.
        move text2 to wa_final-b.
        concatenate wa_Final-a '-' wa_final-b into wa_final-c separated by space.
        wa_final-name1 = wa_kna1-name1.
        wa_final-xblnr = wa_pos-xblnr.
        Loop at it_konv into wa_konv where knumv = wa_vbrk-knumv and  kposn = wa_vbrp-posnr.
          wa_pos-dmshb = ( wa_konv-kwert ) - ( ( wa_konv-kwert * ra_data ) / 100 ).
          wa_final-dmbtr = wa_pos-dmshb.
        Endloop.
      Endloop.
      Append wa_final to it_final
      clear: wa_bkpf, wa_kna1, wa_t005u,wa_vbrk, wa_vbrp, wa_konv, wa_final, wa_pos.
    ENDLOOP.
    Edited by: Matt on Apr 9, 2009 1:20 PM - added  tags

    Position of your append is wrong ...
    it should be above all the endloop.
    Edited:
    LOOP AT it_pos INTO wa_pos .
      *** logic ***
      READ TABLE it_kna1 INTO wa_kna1 WITH KEY kunnr = wa_pos-konto .
      *** logic ***
      read table it_t005u into wa_t005u with key bland = wa_kna1-regio.
      *** logic ***
      Loop at it_vbrp into wa_vbrp where vbeln = wa_bkpf-vbeln.
        *** logic ***
        read table it_vbrk into wa_vbrk with key vbeln = wa_vbrp-vbeln.
        *** logic ***
        Loop at it_konv into wa_konv where knumv = wa_vbrk-knumv and kposn = wa_vbrp-posnr.
          *** logic ***
          Append wa_final to it_final "Check position of this statement.
        Endloop.
      Endloop.
    ENDLOOP.
    Regards,
    Lalit Mohan Gupta.
    Edited by: Lalit Mohan Gupta on Apr 9, 2009 4:45 PM -  Written the skeleton of code. Label Edited

  • How to avoid using bapi_commit inside a loop .

    Hi ,
    Need a help.
    This is a program for uploading business partners in CRM.
    The basic logic of the program is as below:
    -         There are two types of records in the upload file – new/ old ones to be updated
    -         A new record is identified by checking if a BP exits based on the cust id
    -         In case it is a new record certain BAPI’s are called to create a new BP, else the address details, identification etc are updated for the existing one.
    -         SQL analysis of the program showed that the maximum amount of time is taken in INSERT/UPDTAE/COMMIT processes.
    When we raised the issue with SAP , they stated that the problem occurs due to the very high no of BAPI_COMMIT calls which is within the loop.
    The standard BAPI available allows passing of one record at a time. Hence passing multiple records at a time and a single commit did not seem feasible.
    Also while updating since there are different BAPI’s for address and identification it is being called in a sequence and commit issued after each. If commit is excluded it gives a locking error since the first BAPI tends to lock the record and does not allow subsequent BAPI call
    kindly suggest me with a solution of using a less commit for updating series of records.
    The code is as follows:
    *& Report  ZBP_BDCP_ACCTRNSDATA_UPLOAD                                 *
    *& Created By : Radhu Shankar.G                                        *
    *& Purpose    : Program to Create Investors with the transaction       *
    *&              data received from the De-dupe Software.               *
    *& Note       : Can be Executed or scheduled only in Background        *
    REPORT  zbp_bdcp_acctrnsdata_upload LINE-SIZE 255 LINE-COUNT 65 NO STANDARD PAGE HEADING
                                                                       MESSAGE-ID zcrm_upload.
    TABLES : bbp_iu01.
    Selection Screen
    SELECTION-SCREEN: BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    PARAMETERS: p_file TYPE string LOWER CASE OBLIGATORY.
    SELECTION-SCREEN: END OF BLOCK blk1.
    SELECTION-SCREEN: BEGIN OF BLOCK blk2 WITH FRAME TITLE text-002.
    SELECT-OPTIONS:s_email FOR bbp_iu01-email NO INTERVALS.
    SELECTION-SCREEN: END OF BLOCK blk2.
    SELECTION-SCREEN: BEGIN OF BLOCK blk3 WITH FRAME TITLE text-003.
    SELECTION-SCREEN COMMENT /1(72) text-004.
    SELECTION-SCREEN COMMENT /1(72) text-006.
    SELECTION-SCREEN COMMENT /1(72) text-007.
    SELECTION-SCREEN COMMENT /1(72) text-005.
    SELECTION-SCREEN: END OF BLOCK blk3.
    Data Declaration
    Main Upload structure and internal table
    DATA : BEGIN OF i_main,
             cust_id        TYPE bu_bpext,              " Customer ID
             inv_type_code  TYPE crmt_mktpfchr_atvalue, " Investor Type Code
             insti_tag      TYPE crmt_mktpfchr_atvalue, " Retail/Instituitional Tag
             name           TYPE char120,               " Name
             address1       TYPE ad_strspp1,                    " Address1
             address2       TYPE ad_strspp2,                    " Address2
             address3       TYPE ad_street,                     " Address3
             city           TYPE ad_city1,              " City
             state          TYPE t005u-bezei,           " Region/State
             country        TYPE landx50,               " Country
             pin_code       TYPE ad_pstcd1,             " Pin Code
             off_phone1     TYPE ad_tlnmbr,             " Office Telephone Number1
             off_phone2     TYPE ad_tlnmbr,             " Office Telephone Number2
             res_phone1     TYPE ad_tlnmbr,             " Residence Telephone Number1
             res_phone2     TYPE ad_tlnmbr,             " Residence Telephone Number1
             mobile         TYPE ad_mbnmbr1,            " Mobile Number
             email          TYPE ad_smtpadr,                    " Email ID
             birth_date     TYPE bu_birthdt,            " Birth Date
             pan_no         TYPE bu_id_number,          " Pan Number
             lob            TYPE crmt_mktpfchr_atvalue, " Line of Business
             fam_tag        TYPE bu_id_number,          " FAM Tag Number
             mod_date       TYPE sy-datum,              " Modified Date
           END OF i_main.
    DATA : it_main      LIKE i_main            OCCURS 0 WITH HEADER LINE.
    Error file structure and internal table
    DATA : BEGIN OF i_error,
             cust_id        TYPE bu_bpext,              " Customer ID
             inv_type_code  TYPE crmt_mktpfchr_atvalue, " Investor Type Code
             insti_tag      TYPE crmt_mktpfchr_atvalue, " Retail/Instituitional Tag
             name           TYPE char120,                     " Name
             address1       TYPE ad_strspp1,                    " Address1
             address2       TYPE ad_strspp2,                    " Address2
             address3       TYPE ad_street,                     " Address3
             city           TYPE ad_city1,              " City
             state          TYPE t005u-bezei,           " Region/State
             country        TYPE landx50,               " Country
             pin_code       TYPE ad_pstcd1,             " Pin Code
             off_phone1     TYPE ad_tlnmbr,             " Office Telephone Number1
             off_phone2     TYPE ad_tlnmbr,             " Office Telephone Number2
             res_phone1     TYPE ad_tlnmbr,             " Residence Telephone Number1
             res_phone2     TYPE ad_tlnmbr,             " Residence Telephone Number1
             mobile         TYPE ad_mbnmbr1,            " Mobile Number
             email          TYPE ad_smtpadr,                    " Email ID
             birth_date     TYPE bu_birthdt,            " Birth Date
             pan_no         TYPE bu_id_number,          " Pan Number
             lob            TYPE crmt_mktpfchr_atvalue, " Line of Business
             fam_tag        TYPE bu_id_number,          " FAM Tag Number
             mod_date       TYPE sy-datum,              " Modified Date
             bp             TYPE bapibus1006_head-bpartner, " BP
             recno(4)       TYPE c,                         " Record No
             message(255)   TYPE c,                         " Error Message
           END OF i_error.
    DATA : it_error         LIKE i_error            OCCURS 0 WITH HEADER LINE.
    BP Telephone, Email & Role Details
    DATA : w_bp_tel        TYPE bapiadtel,
           it_bp_tel       TYPE bapiadtel             OCCURS 0 WITH HEADER LINE,
           it_bp_tel1      TYPE bapiadtel             OCCURS 0 WITH HEADER LINE,
           it_bp_email     TYPE bapiadsmtp            OCCURS 0 WITH HEADER LINE,
           it_bp_email1    TYPE bapiadsmtp            OCCURS 0 WITH HEADER LINE,
           it_bapicomrem   TYPE STANDARD TABLE OF bapicomrem   WITH HEADER LINE,
           it_bapicomrem_x TYPE STANDARD TABLE OF bapicomrex   WITH HEADER LINE,
           it_tel_x        TYPE STANDARD TABLE OF bapiadtelx   WITH HEADER LINE,
           it_email_x      TYPE STANDARD TABLE OF bapiadsmtx   WITH HEADER LINE,
           it_role         TYPE bapibusisb990_bproles OCCURS 0 WITH HEADER LINE,
           it_role_cp      TYPE bapibusisb990_bproles OCCURS 0 WITH HEADER LINE.
    BP Identication Details
    DATA: BEGIN OF it_identification OCCURS 0,
            idcategory TYPE bapibus1006_identification_key-identificationcategory,
            idnumber   TYPE bapibus1006_identification_key-identificationnumber,
          END OF it_identification.
    DATA : w_identification TYPE bapibus1006_identification.
    BP Marketing Attributes
    DATA : BEGIN OF it_crmt OCCURS 0,
            crmt TYPE crmt_mktprof_keys-profile_template_id,
           END   OF it_crmt.
    DATA : it_crmt1  TYPE STANDARD TABLE OF crmt_mktprof_comw WITH HEADER LINE,
           it_crmt2  TYPE STANDARD TABLE OF crmt_mktprof_comw WITH HEADER LINE,
           it_crmt3  TYPE STANDARD TABLE OF crmt_mktprof_comw WITH HEADER LINE,
           it_crmt4  TYPE STANDARD TABLE OF crmt_mktprof_comw WITH HEADER LINE,
           it_crmt5  TYPE STANDARD TABLE OF crmt_mktprof_comw WITH HEADER LINE,
           it_bp_ret TYPE STANDARD TABLE OF bapiret2 WITH HEADER LINE.
    BP Basic Details
    DATA : v_partn_cat       TYPE bapibus1006_head-partn_cat,
           w_central         TYPE bapibus1006_central,
           w_central_x       TYPE bapibus1006_central_x,
           w_central_org     TYPE bapibus1006_central_organ,
           w_central_per     TYPE bapibus1006_central_person,
           w_central_group   TYPE bapibus1006_central_group,
           w_centralorg_x    TYPE bapibus1006_central_organ_x,
           w_centralperson_x TYPE bapibus1006_central_person_x,
           w_centralgrp_x    TYPE bapibus1006_central_group_x,
           w_address         TYPE bapibus1006_address,
           w_addr_x          TYPE bapibus1006_address_x,
           v_bp              TYPE bapibus1006_head-bpartner.
    Declaration for Duplication Check
    DATA : w_zacc_address  TYPE zacc_address,
           g_dup_status      TYPE i.
    DATA : it_dup_bp TYPE STANDARD TABLE OF zbuspartner WITH HEADER LINE.
    CONSTANTS: c_pan     TYPE bu_id_type  VALUE 'ZID003',
               c_fam_tag TYPE bu_id_type  VALUE 'ZID011',
               c_cust    TYPE bu_id_type  VALUE 'ZID009'.
    Other Declarations
    DATA : v_inv_type      TYPE crmt_mktpfchr_atvalue, " Investor Type Code
           v_file          TYPE string,
           v_firstname     TYPE bu_nameor1,
           v_filename1(14) TYPE c,
           v_filename2(14) TYPE c,
           v_lines         TYPE int4,
           v_cat           TYPE bu_type,
           recno           TYPE int4,
           loopno          TYPE int4,
           it_iden_ret     TYPE bapiret2 OCCURS 0,
           it_attr_ret     TYPE bapiret2 OCCURS 0,
           it_role_ret     TYPE bapiret2 OCCURS 0,
           wa_iden_ret     TYPE bapiret2,
           wa_attr_ret     TYPE bapiret2,
           it_iden_flag    TYPE c,
           it_attr_flag    TYPE c,
           flag_central    TYPE c,
           flag_addr       TYPE c,
           flag_bp         TYPE c,
           flag_suc        TYPE c,
           flag_exist      TYPE c,
           flag_exit       TYPE c,
           g_bp_msg        TYPE string,
           g_bp_msg1       TYPE string.
    DATA : BEGIN OF i_success,
             rec   TYPE  int4,                      "Record
             name  TYPE  bu_nameor1,                "Name
             bp    TYPE  bapibus1006_head-bpartner, "Business Partner
           END OF i_success,
           it_success     LIKE i_success OCCURS 0 WITH HEADER LINE,
           it_upd_success LIKE i_success OCCURS 0 WITH HEADER LINE.
    Data Declaration for converting spool request to PDF and to trigger mail
    DATA : gd_recsize TYPE i.
    Spool IDs
    TYPES : BEGIN OF t_tbtcp.
            INCLUDE STRUCTURE tbtcp.
    TYPES : END OF t_tbtcp.
    DATA : it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
           wa_tbtcp TYPE t_tbtcp.
    Job Runtime Parameters
    DATA : gd_eventid                 LIKE tbtcm-eventid,
           gd_eventparm               LIKE tbtcm-eventparm,
           gd_external_program_active LIKE tbtcm-xpgactive,
           gd_jobcount                LIKE tbtcm-jobcount,
           gd_jobname                 LIKE tbtcm-jobname,
           gd_stepcount               LIKE tbtcm-stepcount,
           gd_error                   TYPE sy-subrc,
           gd_reciever                TYPE sy-subrc.
    DATA : w_recsize TYPE i.
    DATA : gd_subject   LIKE sodocchgi1-obj_descr,
           it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
           it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
           gd_sender_type     LIKE soextreci1-adr_typ,
           gd_attachment_desc TYPE so_obj_nam,
           gd_attachment_name TYPE so_obj_des.
    Spool to PDF conversions
    DATA : gd_spool_nr LIKE tsp01-rqident,
           gd_destination LIKE rlgrap-filename,
           gd_bytecount LIKE tst01-dsize,
           gd_buffer TYPE string.
    Binary store for PDF
    DATA : BEGIN OF it_pdf_output OCCURS 0.
            INCLUDE STRUCTURE tline.
    DATA : END OF it_pdf_output.
    DATA : v_email1 TYPE somlreci1-receiver,
           v_sender TYPE somlreci1-receiver.
    CONSTANTS: c_no(1)     TYPE c   VALUE ' ',
               c_device(4) TYPE c   VALUE 'LOCL',
               c_delspl    TYPE c   VALUE 'X'.
    DATA : BEGIN OF result OCCURS 0,
             line(100) TYPE c,
           END OF result.
    DATA:i_id_tab TYPE STANDARD  TABLE OF bapibus1006_id_details WITH HEADER LINE.
    eliminting the error for convt page error
    data: g_spl type c value ''.
    eliminting the error for convt page error
    Initialization
    Renaming the target file daily
    CONCATENATE '_' sy-datum '.txt' INTO v_filename1.
    CONCATENATE '_' sy-datum '.TXT' INTO v_filename2.
    START-OF-SELECTION
    START-OF-SELECTION.
      SELECT COUNT(*) FROM zbp_tax_status.
      IF sy-subrc <> 0.
        SKIP 2.
        WRITE:/ text-011.
        STOP.
      ENDIF.
      REFRESH : it_main.
    Uploading the file from either presentatinon layer or application server
      PERFORM file_upload.
    Creating the BP number and assigning & adding up other attributes
      LOOP AT it_main.
        PERFORM data_fill.                       " Filling up global structures & variables
       IF v_bp IS INITIAL.
         PERFORM duplication_check.             " Duplication check
       ENDIF.
        PERFORM bp_creation.                     " BP Creation
        PERFORM return_fill.                     " Filling up Return Tables
        CLEAR : v_bp, it_main, flag_exit, g_dup_status, it_identification, it_crmt, it_crmt1, it_crmt2, it_crmt3, it_crmt4, it_crmt5,
                w_bp_tel,it_bp_tel,it_bp_tel1,it_bp_email,it_bp_email1,it_tel_x,it_email_x,w_addr_x,w_centralorg_x,w_centralperson_x,
                w_centralgrp_x,flag_addr,flag_central,it_iden_flag,it_attr_flag,it_bapicomrem,w_central,w_central_x, v_inv_type,it_bapicomrem_x,
                w_central_org,w_central_per,w_central_group,flag_bp,flag_suc,flag_exist,it_bp_ret,g_bp_msg,g_bp_msg1,v_cat,wa_attr_ret.
        REFRESH :it_identification, it_crmt, it_crmt1, it_crmt2, it_crmt3, it_crmt4, it_crmt5,it_bapicomrem,
                 it_bp_tel,it_bp_tel1,it_bp_email,it_bp_email1,it_tel_x,it_email_x,it_bp_ret,it_bapicomrem_x.
      ENDLOOP.
    Downloading the file to be reprocessed to the application server
      IF it_error[] IS NOT INITIAL.
        PERFORM error_file_download.
      ENDIF.
    Constructing the Return Messages for the Job
      PERFORM return_messages.                  " Return Message Construction
    Converting the return messages into PDF file and trigerring a mail notification
      IF sy-batch EQ 'X'.
        PERFORM get_job_details.
        PERFORM obtain_spool_id.
        PERFORM convert_spool_to_pdf.
        PERFORM process_email.
        PERFORM trigger_email.
      ENDIF.
    *&      Form  file_upload
    FORM file_upload .
    Data declatration
      DATA: l_filestr  TYPE string.
      CLASS cl_abap_char_utilities DEFINITION LOAD.
      CONSTANTS: con_tab  TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
      REPLACE '.txt' WITH v_filename1 INTO p_file .
      REPLACE '.TXT' WITH v_filename2 INTO p_file .
      MOVE p_file TO v_file.
      IF sy-batch EQ 'X'.
    Uploading the file from application server if the job is scheduled in background
        OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT
    eliminting the error for convt page error
                                  IGNORING CONVERSION ERRORS REPLACEMENT CHARACTER g_spl.
    eliminting the error for convt page error
        IF sy-subrc = 0.
          DO.
            READ DATASET p_file INTO l_filestr.
            IF sy-subrc <> 0.
              EXIT.
            ELSE.
              CLEAR it_main.
              SPLIT l_filestr  AT con_tab INTO:
                it_main-cust_id        it_main-inv_type_code
                it_main-insti_tag      it_main-name
                it_main-address1       it_main-address2
                it_main-address3       it_main-city
                it_main-state          it_main-country
                it_main-pin_code       it_main-off_phone1
                it_main-off_phone2     it_main-res_phone1
                it_main-res_phone2     it_main-mobile
                it_main-email          it_main-birth_date
                it_main-pan_no         it_main-lob
                it_main-fam_tag        it_main-mod_date.
              APPEND it_main.
            ENDIF.
          ENDDO.
        ELSE.
          WRITE : / 'The file',
                     p_file,
                     'is not found.'.
          STOP.
        ENDIF.
        CLOSE DATASET p_file.
      ELSE.
        WRITE : / 'The Program can only be executed in the background.'.
        STOP.
      ENDIF.
      CLEAR : l_filestr, it_main.
    ENDFORM.                    " file_upload
    *&      Form  data_fill
    FORM data_fill .
    Filling up Partner Category (v_Partn_cat) ,workarea (w_central), workarea (w_central_org) & workarea (w_central_per)
      SELECT SINGLE bp_category tax_status FROM zbp_tax_status
                        INTO (v_partn_cat,v_inv_type)
                        WHERE inv_code EQ it_main-inv_type_code.
    Filling up the Authorization Group
      IF it_main-lob EQ 'M' AND it_main-insti_tag EQ 'N'.
        w_central-authorizationgroup = 'ZMFR'.
      ELSEIF it_main-lob EQ 'M' AND it_main-insti_tag EQ 'Y'.
        w_central-authorizationgroup = 'ZMFI'.
      ELSEIF it_main-lob EQ 'P' AND it_main-insti_tag EQ 'N'.
        w_central-authorizationgroup = 'ZPMR'.
      ELSEIF it_main-lob EQ 'P' AND it_main-insti_tag EQ 'Y'.
        w_central-authorizationgroup = 'ZPMI'.
      ELSEIF it_main-lob EQ 'A' AND it_main-insti_tag EQ 'N'.
        w_central-authorizationgroup = 'ZBOR'.
      ELSEIF it_main-lob EQ 'A' AND it_main-insti_tag EQ 'Y'.
        w_central-authorizationgroup = 'ZBOI'.
      ENDIF.
    Filling up workarea (w_address)
      IF it_main-address1 IS NOT INITIAL.
        MOVE : it_main-address1 TO w_address-str_suppl1,
               it_main-address1 TO w_zacc_address-address1,
               'X'              TO w_addr_x-str_suppl1 .
      ENDIF.
      IF it_main-address2 IS NOT INITIAL.
        MOVE : it_main-address2 TO w_address-str_suppl2,
               it_main-address2 TO w_zacc_address-address2,
               'X'              TO w_addr_x-str_suppl2 .
      ENDIF.
      IF it_main-address3 IS NOT INITIAL.
        MOVE : it_main-address3 TO w_address-street,
               it_main-address3 TO w_zacc_address-address3,
              'X'               TO w_addr_x-street.
      ENDIF.
      IF it_main-city  IS NOT INITIAL.
        MOVE :   it_main-city     TO w_address-city,
                 it_main-city     TO w_zacc_address-city,
                 'X'              TO w_addr_x-city.
      ENDIF.
      IF it_main-pin_code  IS NOT INITIAL.
        MOVE :   it_main-pin_code TO w_address-postl_cod1,
                'X'               TO w_addr_x-postl_cod1.
        TRANSLATE w_address-postl_cod1 TO UPPER CASE.
      ENDIF.
      IF it_main-country IS NOT INITIAL.
        MOVE : 'X' TO w_addr_x-country.
      ENDIF.
      IF it_main-state IS NOT INITIAL.
        MOVE: 'X'  TO w_addr_x-region.
      ENDIF.
    Picking up Country & State Codes
      SELECT SINGLE land1 FROM t005t INTO w_address-country
           WHERE spras   EQ 'E'
             AND landx50 EQ it_main-country.
      IF sy-subrc EQ 0.
        SELECT SINGLE bland FROM t005u INTO w_address-region
             WHERE spras EQ 'E'
               AND land1 EQ w_address-country
               AND bezei EQ it_main-state.
        IF sy-subrc NE 0.
          w_address-region = 'ZZ'.
        ENDIF.
      ELSE.
        w_address-country = 'ZZ'.
        SELECT SINGLE bland FROM t005u INTO w_address-region
             WHERE spras EQ 'E'
               AND land1 EQ w_address-country
               AND bezei EQ it_main-state.
        IF sy-subrc NE 0.
          w_address-region = 'ZZ'.
        ENDIF.
      ENDIF.
      w_zacc_address-country = w_address-country.
      w_zacc_address-state   = w_address-region.
    Filling up the BP Role Detail
      it_role-partnerrole = 'Z1INVS'.
      APPEND it_role.
    Finding out the BP number from the client ID
      IF it_main-cust_id IS NOT INITIAL.
        SELECT SINGLE partner FROM but0id INTO  v_bp
                      WHERE type     EQ 'ZID009'
                        AND idnumber EQ it_main-cust_id.
        IF sy-subrc = 0.
          SELECT SINGLE type FROM but000 INTO v_cat
                              WHERE partner = v_bp.
          PERFORM name_processing USING v_cat.
        ENDIF.
      ENDIF.
      IF v_bp IS INITIAL.
        PERFORM name_processing USING v_partn_cat.    " Processing the Name & Title depending on partner category
    Filling up the Identication Number Details
        IF it_main-cust_id IS NOT INITIAL.        " Customer ID
          it_identification-idcategory = 'ZID009'.
          it_identification-idnumber   = it_main-cust_id.
          APPEND it_identification.
          CLEAR  it_identification.
        ENDIF.
        IF it_main-pan_no IS NOT INITIAL.        " Pan Number
          it_identification-idcategory = 'ZID003'.
          it_identification-idnumber   = it_main-pan_no.
          APPEND it_identification.
          CLEAR  it_identification.
        ENDIF.
        IF it_main-fam_tag IS NOT INITIAL.        " Family Tag Number
          it_identification-idcategory = 'ZID011'.
          it_identification-idnumber   = it_main-fam_tag.
          APPEND it_identification.
          CLEAR  it_identification.
        ENDIF.
    Filling up the Marketing Attributes
       IF v_inv_type IS NOT INITIAL.                 " Tax status
         it_crmt1-atname = 'TAX_STATUS'.
         it_crmt1-atwrt  =  v_inv_type.
         APPEND it_crmt1.
         CLEAR : it_crmt1.
       ENDIF.
       IF it_main-lob IS NOT INITIAL.                " Product Tag
         it_crmt1-atname   = 'LOB'.
         IF it_main-lob EQ 'M'.
           it_crmt1-atwrt  = 'MF'.
         ELSEIF it_main-lob EQ 'P'.
           it_crmt1-atwrt  = 'PMS'.
         ELSEIF it_main-lob EQ 'A'.
           it_crmt1-atwrt  = 'BOTH'.
         ENDIF.
         APPEND it_crmt1.
         CLEAR : it_crmt1.
       ENDIF.
       IF it_main-insti_tag IS NOT INITIAL.         " Retail/Instituitional Tag
         it_crmt1-atname   = 'ORGANISATION_STRUCTURE'.
         IF it_main-insti_tag EQ 'N'.
           it_crmt1-atwrt  = 'RETAIL'.
         ELSEIF it_main-insti_tag EQ 'Y'.
           it_crmt1-atwrt  = 'INSTITUTIONAL'.
         ELSEIF it_main-insti_tag EQ 'F'.
           it_crmt1-atwrt  = 'INTERNATIONAL'.
         ENDIF.
         APPEND it_crmt1.
         CLEAR : it_crmt1.
       ENDIF.
       it_crmt2-atname = 'VIP'.
       it_crmt2-atwrt  = 'NOT CLASSIFIED'.
       APPEND it_crmt2.
       CLEAR : it_crmt2.
       it_crmt3-atname = 'PRIORITY'.
       it_crmt3-atwrt  = 'NOT CLASSIFIED'.
       APPEND it_crmt3.
       CLEAR : it_crmt3.
       it_crmt4-atname = 'CONTACTBLE'.
       it_crmt4-atwrt  = 'NOT CLASSIFIED'.
       APPEND it_crmt4.
       CLEAR : it_crmt4.
       it_crmt5-atname = 'SOURCE'.
       it_crmt5-atwrt  = 'CAMS'.
       APPEND it_crmt5.
       CLEAR : it_crmt5.
       it_crmt-crmt = 'CENTALISED_CLF_INV'.
       APPEND it_crmt.
       it_crmt-crmt = 'GENERAL_CLF_INV'.
       APPEND it_crmt.
       it_crmt-crmt = 'MF_CLF_INV'.
       APPEND it_crmt.
       it_crmt-crmt = 'PMS_CLF_INV'.
       APPEND it_crmt.
       it_crmt-crmt = 'SOURCE'.
       APPEND it_crmt.
       CLEAR it_crmt-crmt.
      ENDIF.
    For Return Message
      recno = recno + 1.
    ENDFORM.                    " data_fill
    *&      Form  duplication_check
    FORM duplication_check .
      DATA : l_lines TYPE i.
      IF v_firstname IS NOT INITIAL.
        CALL FUNCTION 'ZACC_DUPLICATIONCHECK'
          EXPORTING
            role            = 'Z1INVS'
            firstname       = v_firstname
            pan_no          = it_main-pan_no
            mobile          = it_main-mobile
            email           = it_main-email
            address         = w_zacc_address
            partnercategory = v_partn_cat
          IMPORTING
            status          = g_dup_status
          TABLES
            buspartner      = it_dup_bp.
        DESCRIBE TABLE it_dup_bp LINES l_lines.
        IF l_lines EQ 1.
          IF g_dup_status EQ 1.
            READ TABLE it_dup_bp INDEX 1.
            MOVE it_dup_bp-partner TO v_bp.
          ELSEIF g_dup_status EQ 2.
            flag_exit = 'X'.
          ENDIF.
        ELSEIF l_lines GT 1.
          flag_exit = 'X'.
        ENDIF.
      ENDIF.
      CLEAR : l_lines, v_firstname.
    ENDFORM.                    " duplication_check
    *&      Form  name_processing
    FORM name_processing USING uv_cat TYPE bu_type.
      IF it_main-name IS NOT INITIAL.
      If category is Person
        IF uv_cat EQ 1.
          CALL FUNCTION 'ZGET_NAME_FROM_STRING'
            EXPORTING
              name   = it_main-name
            IMPORTING
              first  = w_central_per-firstname
              middle = w_central_per-middlename
              last   = w_central_per-lastname.
          w_centralperson_x-firstname  = 'X'.
          w_centralperson_x-middlename = 'X'.
          w_centralperson_x-lastname   = 'X'.
          w_centralperson_x-birthdate  = 'X'.
          MOVE : it_main-birth_date TO w_central_per-birthdate,
                 w_central_per-firstname TO v_firstname.
        ELSEIF uv_cat EQ 2.
        If category is organisation
          CALL FUNCTION 'ZGET_NAME_FROM_STRING'
            EXPORTING
              name   = it_main-name
            IMPORTING
              first  = w_central_org-name2
              middle = w_central_org-name1
              last   = w_central_org-name3.
          w_centralorg_x-name1 = 'X'.
          w_centralorg_x-name2 = 'X'.
          w_centralorg_x-name3 = 'X'.
          MOVE w_central_org-name2 TO v_firstname.
        ELSEIF uv_cat EQ 3.
        If category is group
          CALL FUNCTION 'ZGET_NAME_FROM_STRING'
            EXPORTING
              name   = it_main-name
            IMPORTING
              first  = w_central_group-namegroup2
              middle = w_central_group-namegroup1.
          w_centralgrp_x-namegroup1 = 'X'.
          w_centralgrp_x-namegroup2 = 'X'.
          MOVE w_central_group-namegroup2 TO v_firstname.
        ENDIF.
        MOVE : it_main-name+0(8)    TO w_central-searchterm1,
               'X'                  TO w_central_x-searchterm1.
      ENDIF.
    ENDFORM.                    " name_processing
    *&      Form  bp_creation
    FORM bp_creation.
      DATA:l_identification   TYPE bapibus1006_identification_key-identificationnumber.
    BP Creation
      IF v_bp IS INITIAL.
    Filling up the Telephone Details
        MOVE : w_address-country TO w_bp_tel-country.
        IF it_main-off_phone1 IS NOT INITIAL.     " Office Telephone1
          w_bp_tel-r_3_user  = '1'.
          w_bp_tel-telephone = it_main-off_phone1.
          APPEND w_bp_tel TO it_bp_tel.
          CLEAR : w_bp_tel-r_3_user, w_bp_tel-telephone.
          it_bapicomrem-comm_type  = 'TEL'.
          it_bapicomrem-langu      = 'EN'.
          it_bapicomrem-comm_notes = 'OFFICE PHONE1'.
          APPEND it_bapicomrem.
        ENDIF.
        IF it_main-off_phone2 IS NOT INITIAL.     " Office Telephone2
          w_bp_tel-telephone = it_main-off_phone2.
          APPEND w_bp_tel TO it_bp_tel.
          CLEAR : w_bp_tel-telephone.
          it_bapicomrem-comm_type  = 'TEL'.
          it_bapicomrem-langu      = 'EN'.
          it_bapicomrem-comm_notes = 'OFFICE PHONE2'.
          APPEND it_bapicomrem.
        ENDIF.
        IF it_main-res_phone1 IS NOT INITIAL.     " Residence Telephone1
          w_bp_tel-telephone = it_main-res_phone1.
          APPEND w_bp_tel TO it_bp_tel.
          CLEAR : w_bp_tel-telephone.
          it_bapicomrem-comm_type  = 'TEL'.
          it_bapicomrem-langu      = 'EN'.
          it_bapicomrem-comm_notes = 'RESIDENCE PHONE1'.
          APPEND it_bapicomrem.
        ENDIF.
        IF it_main-res_phone2 IS NOT INITIAL.     " Residence Telephone2
          w_bp_tel-telephone = it_main-res_phone2.
          APPEND w_bp_tel TO it_bp_tel.
          CLEAR : w_bp_tel-telephone.
          it_bapicomrem-comm_type  = 'TEL'.
          it_bapicomrem-langu      = 'EN'.
          it_bapicomrem-comm_notes = 'RESIDENCE PHONE2'.
          APPEND it_bapicomrem.
        ENDIF.
        IF it_main-mobile IS NOT INITIAL.         " Mobile Number
          w_bp_tel-r_3_user  = '3'.
          w_bp_tel-telephone = it_main-mobile.
          APPEND w_bp_tel TO it_bp_tel.
          CLEAR : w_bp_tel-r_3_user, w_bp_tel-telephone.
        ENDIF.
    Filling up the E-Mail Details
        IF it_main-email IS NOT INITIAL.                        " E-mail1
          it_bp_email-e_mail = it_main-email.
          APPEND it_bp_email.
          CLEAR it_bp_email.
        ENDIF.
      BAPI for BP creation
        CALL FUNCTION 'BAPI_BUPA_FS_CREATE_FROM_DATA2'
          EXPORTING
            partnercategory         = v_partn_cat
            centraldata             = w_central
            centraldataperson       = w_central_per
            centraldataorganization = w_central_org
            centraldatagroup        = w_central_group
            addressdata             = w_address
          IMPORTING
            businesspartner         = v_bp
          TABLES
            telefondata             = it_bp_tel
            communicationnotes      = it_bapicomrem
            e_maildata              = it_bp_email
            roles                   = it_role
            return                  = it_bp_ret.
        IF v_bp IS NOT INITIAL.
          flag_bp = 'X'.
        ENDIF.
      Commiting the transaction
        PERFORM transaction_commit.
      To add Identification details to BP
        PERFORM add_details.
        CLEAR   : v_partn_cat, w_central, w_central_per, w_central_org, it_bp_tel, it_bp_email, it_role.
        REFRESH : it_bp_tel, it_bp_email, it_role.
      ELSE.
        flag_exist = 'X'.
    If BP exists,address,communication and ID details will be updated
        CALL FUNCTION 'BAPI_BUPA_CENTRAL_CHANGE'
          EXPORTING
            businesspartner           = v_bp
            centraldata               = w_central
            centraldataperson         = w_central_per
            centraldataorganization   = w_central_org
            centraldatagroup          = w_central_group
            centraldata_x             = w_central_x
            centraldataperson_x       = w_centralperson_x
            centraldataorganization_x = w_centralorg_x
            centraldatagroup_x        = w_centralgrp_x
          TABLES
            return                    = it_bp_ret.
        READ TABLE it_bp_ret WITH KEY type = 'E'.
        IF sy-subrc = 0.
          flag_central = 'E'.
          g_bp_msg  = it_bp_ret-message.
          CLEAR:it_bp_ret.
          REFRESH:it_bp_ret.
        ELSE.
          flag_suc = 'X'.
        ENDIF.
        PERFORM transaction_commit.
    To get the existing communication details
        CALL FUNCTION 'BAPI_BUPA_ADDRESS_GETDETAIL'
          EXPORTING
            businesspartner = v_bp
          TABLES
            bapiadtel       = it_bp_tel1
            bapiadsmtp      = it_bp_email1.
        LOOP AT it_bp_tel1 WHERE r_3_user = '1' OR r_3_user = ' '.
          it_bp_tel-consnumber = it_bp_tel1-consnumber.
          it_tel_x-updateflag     = 'D'.
          APPEND:it_bp_tel,
                 it_tel_x.
          CLEAR: it_bp_tel,
                 it_tel_x.
        ENDLOOP.
        IF it_main-mobile  IS NOT INITIAL .
          LOOP AT it_bp_tel1 WHERE r_3_user = '2' OR r_3_user = '3'.
            it_bp_tel-consnumber = it_bp_tel1-consnumber.
            it_tel_x-updateflag     = 'D'.
            APPEND:it_bp_tel,
                   it_tel_x.
            CLEAR: it_bp_tel,
                   it_tel_x.
          ENDLOOP.
        ENDIF.
    *Updating communication details
        IF it_main-off_phone1 IS NOT INITIAL.     " Office Telephone1
          w_bp_tel-r_3_user  = '1'.
          w_bp_tel-telephone = it_main-off_phone1.
          it_tel_x-telephone     = 'I'.
          it_tel_x-updateflag    = 'I'.
          APPEND:it_tel_x.
          CLEAR: it_tel_x.
          APPEND w_bp_tel TO it_bp_tel.
          CLEAR : w_bp_tel-r_3_user, w_bp_tel-telephone.
          it_bapicomrem-comm_type  = 'TEL'.
          it_bapicomrem-langu      = 'EN'.
          it_bapicomrem-comm_notes = 'OFFICE PHONE1'.
          APPEND it_bapicomrem.
          it_bapicomrem_x-comm_type  = 'I'.
          it_bapicomrem_x-langu      = 'I'.
          it_bapicomrem_x-comm_notes = 'I'.
          it_bapicomrem_x-updateflag = 'I'.
          APPEND it_bapicomrem_x.
        ENDIF.
        IF it_main-off_phone2 IS NOT INITIAL.     " Office Telephone2
          w_bp_tel-telephone = it_main-off_phone2.
          APPEND w_bp_tel TO it_bp_tel.
          it_tel_x-telephone     = 'I'.
          it_tel_x-updateflag    = 'I'.
          APPEND:it_tel_x.
          CLEAR:it_tel_x.
          CLEAR : w_bp_tel-telephone.
          it_bapicomrem-comm_type  = 'TEL'.
          it_bapicomrem-langu      = 'EN'.
          it_bapicomrem-comm_notes = 'OFFICE PHONE2'.
          APPEND it_bapicomrem.
          it_bapicomrem_x-comm_type  = 'I'.
          it_bapicomrem_x-langu      = 'I'.
          it_bapicomrem_x-comm_notes = 'I'.
          it_bapicomrem_x-updateflag = 'I'.
          APPEND it_bapicomrem_x.
        ENDIF.
        IF it_main-res_phone1 IS NOT INITIAL.     " Residence Telephone1
          w_bp_tel-telephone = it_main-res_phone1.
          APPEND w_bp_tel TO it_bp_tel.
          it_tel_x-telephone     = 'I'.
          it_tel_x-updateflag    = 'I'.
          APPEND:it_tel_x.
          CLEAR:it_tel_x.
          CLEAR : w_bp_tel-telephone.
          it_bapicomrem-comm_type  = 'TEL'.
          it_bapicomrem-langu      = 'EN'.
          it_bapicomrem-comm_notes = 'RESIDECE PHONE1'.
          APPEND it_bapicomrem.
          it_bapicomrem_x-comm_type  = 'I'.
          it_bapicomrem_x-langu      = 'I'.
          it_bapicomrem_x-comm_notes = 'I'.
          it_bapicomrem_x-updateflag = 'I'.
          APPEND it_bapicomrem_x.
        ENDIF.
        IF it_main-res_phone2 IS NOT INITIAL.     " Residence Telephone2
          w_bp_tel-telephone = it_main-res_phone2.
          APPEND w_bp_tel TO it_bp_tel.
          it_tel_x-telephone     = 'I'.
          it_tel_x-updateflag    = 'I'.
          APPEND:it_tel_x.
          CLEAR:it_tel_x.
          CLEAR : w_bp_tel-telephone.
          it_bapicomrem-comm_type  = 'TEL'.
          it_bapicomrem-langu      = 'EN'.
          it_bapicomrem-comm_notes = 'RESIDECE PHONE2'.
          APPEND it_bapicomrem.
          it_bapicomrem_x-comm_type  = 'I'.
          it_bapicomrem_x-langu      = 'I'.
          it_bapicomrem_x-comm_notes = 'I'.
          it_bapicomrem_x-updateflag = 'I'.
          APPEND it_bapicomrem_x.
        ENDIF.
        IF it_main-mobile IS NOT INITIAL.         " Mobile Number
          w_bp_tel-r_3_user  = '3'.
          w_bp_tel-telephone = it_main-mobile.
          APPEND w_bp_tel TO it_bp_tel.
          it_tel_x-telephone     = 'I'.
          it_tel_x-updateflag    = 'I'.
          APPEND:it_tel_x.
          CLEAR:it_tel_x.
          CLEAR : w_bp_tel-r_3_user, w_bp_tel-telephone.
        ENDIF.
        IF it_main-email IS NOT INITIAL.
          LOOP AT it_bp_email1.
            it_bp_email-consnumber   = it_bp_email1-consnumber.
            it_email_x-updateflag    = 'D'.
            APPEND:it_bp_email,
                   it_email_x.
          ENDLOOP.
          it_bp_email-e_mail    =   it_main-email.
          it_email_x-e_mail     = 'I'.
          it_email_x-updateflag = 'I'.
          APPEND:it_bp_email,
                 it_email_x.
          CLEAR:it_bp_email,
                it_email_x.
        ENDIF.
        REFRESH:it_bp_ret.
    BP Change
        CALL FUNCTION 'BAPI_BUPA_ADDRESS_CHANGE'
          EXPORTING
            businesspartner = v_bp
            addressdata     = w_address
            addressdata_x   = w_addr_x
          TABLES
            bapiadtel       = it_bp_tel
            bapicomrem      = it_bapicomrem
            bapiadtel_x     = it_tel_x
            bapiadsmtp      = it_bp_email
            bapiadsmt_x     = it_email_x
            bapicomre_x     = it_bapicomrem_x
            return          = it_bp_ret.
        READ TABLE it_bp_ret WITH KEY type = 'E'.
        IF sy-subrc = 0.
          flag_addr = 'E'.
          g_bp_msg1 = it_bp_ret-message.
        ELSE.
          flag_suc = 'X'.
        ENDIF.
        PERFORM transaction_commit.
        REFRESH it_bp_ret.
        IF it_main-pan_no IS NOT INITIAL OR it_main-fam_tag IS NOT INITIAL OR it_main-cust_id IS NOT INITIAL.
        Retreiving the existing Identification details
          PERFORM id_get USING v_bp.
        ENDIF.
      PAN number addition
        IF it_main-pan_no IS NOT INITIAL.
          CLEAR l_identification.
          MOVE it_main-pan_no TO l_identification.
          TRANSLATE l_identification TO UPPER CASE.
          READ TABLE i_id_tab WITH KEY identificationtype = c_pan.
          IF sy-subrc = 0.
          To remove existing PAN number
            PERFORM id_remove USING v_bp c_pan i_id_tab-identificationnumber.
            READ TABLE it_iden_ret INTO wa_iden_ret WITH KEY type = 'E'.
            IF sy-subrc EQ 0.
              it_iden_flag = 'E'.
            ELSE.
              flag_suc = 'X'.
            Performing transaction commit
              PERFORM transaction_commit.
            ENDIF.
          ENDIF.
          CLEAR:it_iden_ret[],it_iden_ret.
        To add new PAN number
          PERFORM id_add USING v_bp c_pan l_identification.
          READ TABLE it_iden_ret INTO wa_iden_ret WITH KEY type = 'E'.
          IF sy-subrc EQ 0.
            it_iden_flag = 'E'.
          ELSE.
            flag_suc = 'X'.
            PERFORM transaction_commit.
          ENDIF.
        ENDIF.
       Customer ID addition
        IF it_main-cust_id IS NOT INITIAL AND (  g_dup_status = 1 ).
          CLEAR l_identification.
          MOVE it_main-cust_id  TO l_identification.
          TRANSLATE l_identification TO UPPER CASE.
          READ TABLE i_id_tab WITH KEY identificationtype = c_cust.
          IF sy-subrc = 0.
          To remove existing Customer ID
            PERFORM id_remove USING v_bp c_cust i_id_tab-identificationnumber.
            READ TABLE it_iden_ret INTO wa_iden_ret WITH KEY type = 'E'.
            IF sy-subrc EQ 0.
              it_iden_flag = 'E'.
            ELSE.
          Performing transaction commit
              PERFORM transaction_commit.
            ENDIF.
          ENDIF.
          CLEAR:it_iden_ret[],it_iden_ret.
        To add new Customer ID number
          PERFORM id_add USING v_bp c_cust l_identification.
          READ TABLE it_iden_ret INTO wa_iden_ret WITH KEY type = 'E'.
          IF sy-subrc EQ 0.
            it_iden_flag = 'E'.
          ELSE.
            flag_suc ='X'.
            PERFORM transaction_commit.
          ENDIF.
        ENDIF.
      To add marketing attributes
       IF it_main-insti_tag IS NOT INITIAL AND it_main-lob IS NOT INITIAL.
         PERFORM add_makt_attr .
       ELSE.
         it_attr_flag = 'E'.

    Guy&#65292;i don't regard here is anybody wanna read so much code .For more constructive answers, you would distill core question from your program.

  • How to show two or more PDF in one PDF-Reader / Concatenate PDF-Files

    Hi,
    I want to show two or more PDF files in one PDF reader window or to concatenate two or mor PDF files to one file.
    We use WD4A and ADS.
    Have someone an idea to solve this without an external program?
    Thx in advance
    Jürgen

    We have done this successfully a few times using WDA - it wasn't easy - it took us 2 full weeks to figure it out, so i need to get full points for this one!
    It's going to much easier to do this if you start a brand new WDA. If not, you'll have to re-do all your Context Node navigations within your methods.
    The first thing you need to do is to define your Context properly:
    You need a top level Node defined as 1:1 cardinality (as with all PDF development)
    Next, you need another Container Node 1:n cardinality (this holds the collection of content nodes)
    Finally, you have your PDF Content Node 1:n cardinality - This holds each instance of your PDF form
    In our scenario, we are passed in a list of Project Numbers. We need to generate a PDF sheet for each project in the same PDF session.
    pseudo code - i'm leaving out some of the unnessary details
    Loop through the project number table.
    ADD 1 TO v_cnt.
    * navigate from <TOP> to <PDF_CONTAINER> via lead selection
        lo_nd_pdf_container = lo_nd_top->get_child_node( name = wd_this->wdctx_pdf_container ).
    * This is the Important Part - we check to see if there is an element where index = v_cnt
    * If not, we create one where we can store the new set of data
    * get element via lead selection
        lo_el_pdf_container = lo_nd_pdf_container->get_element( index = v_cnt ).
        IF lo_el_pdf_container IS INITIAL.
          lo_el_pdf_container  = lo_nd_pdf_container->create_element( ).
          lo_nd_pdf_container->bind_element( new_item = lo_el_pdf_container
                                               set_initial_elements = ' '   ).
        ENDIF.
        lo_nd_ideasheet_data =  lo_el_pdf_container->get_child_node( 'IDEASHEET_DATA' ).
        lo_el_ideasheet_data = lo_nd_ideasheet_data->get_element( index = 1 ).
    * fill all the data then bind the structure
    Select * from XXX into lt_XXX
      where project_number = lt_project-project_number.
    * Move Data to appropriate fields/tables
    * Bind the info back to the element
        lo_el_ideasheet_data->set_static_attributes( static_attributes =
                                                  ls_ideasheet_data ).
    Endloop.

  • How to concatenate multiple records into one

    Hi everybody:
    I want to know if exist some way to concat multiple records into one without using cursors. For example, I have a table named "Authors" like this:
    Lan|Author
    English|Ernest Hemingway
    Spanish|Octavio Paz
    Spanish|Mario Vargas Llosa
    English|Sinclair Lewis
    Spanish|Gabriel García Márquez
    And I want to get this:
    Author
    Octavio Paz, Mario Vargas Llosa, Gabriel García Márquez
    I have worked with SQL Server and I can do something like this:
    CREATE FUNCTION dbo.MyConcat (@lan varchar(10))
    RETURNS varchar(5000) AS
    BEGIN
    declare @retvalue varchar(5000)
    set @retvalue=''
    select @retvalue = @retvalue + Author +',' from Authors where lan = @lan
    return substring(@retvalue,1,len(@retvalue)-1)
    END
    ie, do not use cursors to concatenate records. However, with ORACLE, I have to do someting like this.
    FUNCTION MyConcat(P_Lan IN VARCHAR2) RETURN VARCHAR2 IS
    v_ret VARCHAR2(4000);
    v_element VARCHAR2(4000);
    v_cursor sys_refcursor;
    BEGIN
    OPEN v_cursor FOR SELECT Author FROM Authors where Lan = P_Lan
    LOOP
    FETCH v_cursor INTO v_elemento;
    EXIT WHEN v_cursor%NOTFOUND;
    IF v_ret IS NULL THEN
    v_ret := v_element;
    ELSE
    v_ret := v_ret || ', ' || v_element;
    END IF;
    END LOOP;
    RETURN v_ret;
    END;
    Exist some other way to do this?
    Best Regards
    Jack

    Tks both for answer... I forgot to mention that I am using Oracle 10g. I read about LISTAGG() but this function is available for Oracle 11g release 2.
    I wil read about the other techniques than Hoek mention
    Best Regards.
    Jack

  • How to use different field symbols to append data in a loop

    Hi experts!
    I have to loop over a itab and I want to save different  into one table.
    See my code below:
    DATA: l_hours        TYPE i,
          grfk_ok_code    TYPE sy-ucomm,
          grfk_values     TYPE TABLE OF GPRVAL WITH HEADER LINE,
          grfk_coltxt     TYPE TABLE OF GPRTXT WITH HEADER LINE,
          wa_ztab         TYPE zqm_chq_prueflos,
          l_index      TYPE n,
          l_field      TYPE string,
          l_line_check TYPE string
    FIELD-SYMBOLS:
          <fs_0102>   TYPE ANY,
          <fs_0304>   TYPE ANY,
          <fs_0506>   TYPE ANY,
          <fs_grenze> TYPE ANY
    REFRESH: grfk_values.
    CLEAR:   l_hours.
      LOOP AT ztab INTO wa_ztab.
      AT NEW qase_serialnr.
        CLEAR: l_line_check.
        IF wa_ztab-qase_serialnr CS '-01'
        OR wa_ztab-qase_serialnr CS '-02'.
            grfk_values-rowtxt = 'gelötet'.
            l_line_check = '0102'.
        ELSEIF wa_ztab-qase_serialnr CS '-03'
        OR     wa_ztab-qase_serialnr CS '-04'.
            grfk_values-rowtxt = 'geglüht'.
            l_line_check = '0304'.
        ELSEIF wa_ztab-qase_serialnr CS '-05'
        OR     wa_ztab-qase_serialnr CS '-06'.
            grfk_values-rowtxt = 'unbehandelt'.
            l_line_check = '0506'.
        ELSE.
          grfk_values-rowtxt = 'serialnr_wrong'.
        ENDIF.
      ENDAT.
    ***---------------------------------------------------->
      AT NEW qapp_usern1.
    *   X-axis: values are:0,50,100,...,400
        grfk_coltxt-coltxt = wa_ztab-qapp_usern1.
        SHIFT grfk_coltxt-coltxt LEFT DELETING LEADING '0'.
        APPEND grfk_coltxt.
        UNASSIGN <fs_grenze>.
        CLEAR: l_index, l_field.
        l_index = sy-tabix.
        CONCATENATE 'grfk_values-val' l_index INTO l_field.
        ASSIGN (l_field) TO <fs_grenze>.
        IF sy-subrc <> 0.
          EXIT.
        ENDIF.
        <fs_grenze> = 10.
        APPEND grfk_values.
      ENDAT.
      IF l_line_check = '0102'.
          UNASSIGN <fs_0102>.
          CLEAR: l_index, l_field.
          l_index = sy-tabix.
          CONCATENATE 'grfk_values-val' l_index INTO l_field.
          ASSIGN (l_field) TO <fs_0102>.
          IF sy-subrc <> 0.
            EXIT.
          ENDIF.
          <fs_0102> = wa_ztab-cf_dgp.
      ELSEIF l_line_check = '0304'.
          UNASSIGN <fs_0304>.
          CLEAR: l_index, l_field.
          l_index = sy-tabix.
          CONCATENATE 'grfk_values-val' l_index INTO l_field.
          ASSIGN (l_field) TO <fs_0304>.
          IF sy-subrc <> 0.
            EXIT.
          ENDIF.
          <fs_0304> = wa_ztab-cf_dgp.
      ELSEIF l_line_check = '0506'.
          UNASSIGN <fs_0506>.
          CLEAR: l_index, l_field.
          l_index = sy-tabix.
          CONCATENATE 'grfk_values-val' l_index INTO l_field.
          ASSIGN (l_field) TO <fs_0506>.
          IF sy-subrc <> 0.
            EXIT.
          ENDIF.
          <fs_0506> = wa_ztab-cf_dgp.
      ENDIF.
    ENDLOOP.
    My goal should be to fill the graphic with 4 Lines:
    1 is boarderline.
    2-3 are the lines with the looped values in "ztab"
    Do I have to use references to write the values in  into different rows of internal table "grfk_values"????
    With this code I want to fill the itab which I need for the GFW_PRES_SHOW function.
    The table I have to commit has the following structure:
    -rowtxt
    -val1
    -val2
    -val31
    EDIT:
    My current output are 2 lines the first has value 0 for each point and the second shows the correct values... The boarder which always should have value 10 is completly not shown.

    hopen this will help
    report zrich_0001 .
    data: begin of itab1 occurs 0,
          fld1(10) type c,
          fld2(10) type c,
          fld3(10) type c,
          end of itab1.
    data: begin of itab2 occurs 0,
        flda(10) type c,
        fldb(10) type c,
        fldc(10) type c,
        end of itab2.
    field-symbols: <fs_table> type table,
                   <fs_wa>,
                   <fs>.
    data: mod_field(10) type c.
    itab1-fld1 = '1'. itab1-fld2 = '2'. itab1-fld3 = '3'. append itab1.
    itab1-fld1 = '4'. itab1-fld2 = '5'. itab1-fld3 = '6'. append itab1.
    itab2-flda = 'A'. itab2-fldb = 'B'. itab2-fldc = 'C'. append itab2.
    itab2-flda = 'D'. itab2-fldb = 'E'. itab2-fldc = 'F'. append itab2.
    assign itab1[] to <fs_table>.
    assign itab1 to <fs_wa>.
    mod_field = 'FLD2'.
    perform modify_table.
    perform write_table.
    assign itab2[] to <fs_table>.
    assign itab2 to <fs_wa>.
    mod_field = 'FLDC'.
    perform modify_table.
    perform write_table.
          FORM modify_table                                             *
    form modify_table.
      loop at <fs_table> into <fs_wa>.
        assign component mod_field of structure <fs_wa> to <fs>.
        <fs> = 'Modified'.
        modify <fs_table> from <fs_wa>.
      endloop.
    endform.
          FORM write_table                                             *
    form write_table.
      loop at <fs_table> into <fs_wa>.
        do.
          assign component sy-index of structure <fs_wa> to <fs>.
          if sy-subrc <> 0.
            exit.
          endif.
          if sy-index = 1.
            write:/ <fs>.
          else.
            write: <fs>.
          endif.
        enddo.
      endloop.
    endform.
    regards
    navjot
    reward points if helpfull

  • Concatenate multiple records into one single record

    Hello everyone,
    Can anyone guide me how to merge multiple records into one single record
    like......... I am getting the data in the file like
    aaaaa/bbbbbbb/ccccccccccc/dddddddddddd/eee
    ffffff/gggg/hhhhhhhhhhhhhh
    /123/4567/55555/99999999/kaoabfa/eee
    fffff/kkkkkkkk/llllllllllllllllllllllll
    when i use gui_upload I am getting the data into the internal table in the above format.
    My main intension is to split the record at / to multiple lines and dowload it into another file.
    What i am planning to do is... if the line does not start with / then i want to concatenate the multiple lines into single line and then split it into multiple records. Can anyone guide me how to achieve this.

    Yes, it should work.
    In my example
    Loop at itab.
    concatenate i_text itab into i_text.
    endloop.
    You change that loop for the loop of your internal table with the file records
    So if you have this three records
    'aaaa/bbb/ccc'
    '/dddd/efg'
    'hijk/lmn'
    i_text will look like this at the end
    'aaaa/bbb/ccc/dddd/efghijk/lmn'
    then in this part of the code
    split i_text at '/' into table itab2.
    itab2 will have the records looking like this
    aaaa
    bbb
    ccc
    dddd
    efghijk
    lmn'

  • Infinite loop problem

    Hi there,
    This is the second time I have posted this problem, as the last solution I was offered did not seem to work. Here is the problem:
    I have written a method to search through a text file for a word and replace it with another word. That word can either be on its own in the document or as part of another word. So, if the search word was "foot" and the replace word was "dog", the word "football" in the document would become "dogball".
    This method works fine, except for when the replace word is the same as the search word. Basically, if someone searched for "dog" and wanted to replace it with "dog dog" or even just "dog", the program goes into an infinite loop. I understand why it is doing this, but I don't know how to prevent it from happening.
    Now, to make it worse I have to stick to this array style structure and method of solving the problem. I know there is a way to do this by building temporary strings and then concatenating them at the end and returning them to their previous position in the array. The reason I know this is because a friend of mine has managed it. She also happens to be a girl.
    So, I am asking you all to assist in defending men's intelligence by helping me see where I am going wrong in this method. Please.
    Here is the method:
    // Search the document for a string and replace it with another string        
         public String [] SearchReplace() {
              // Declare variables to be used in the method
              String SecondSubstring;
              String FirstSubstring;
              int ReplaceNumber = 0;
              // Loop through the lines of text stored as strings contained in the array
              for (int i = 0; i < NumberOfLines; i++) {
                        // As long as the string contains an instance of the search string, run the method                    
                        while (StrArray.indexOf(SearchW) >= 0) {
                             // Make a string of all the characters after the search word
                             SecondSubstring = StrArray[i].substring(StrArray[i].indexOf(SearchW) + SearchW.length());
                             // Make a string of all the characters before the search word
                             FirstSubstring = StrArray[i].substring(0, StrArray[i].indexOf(SearchW));
                             // Concatenate FirstSubstring with the replace word to make a new string
                             String FirstHalf = FirstSubstring.concat(ReplaceW);
                             // Concatenate the new string with SecondSubstring to make the whole replaced string
                             String FullString = FirstHalf.concat(SecondSubstring);
                             // Put this altered string back to its original place in the array
                             StrArray[i] = FullString;
                             // Increment ReplaceNumber to count the replacements made
                             ReplaceNumber++;
              // Print the numbers of replacements made
              System.out.println("\nA total of " + ReplaceNumber + " changes made.\n");
              // Display the searched and replaced contents of the file
              return StrArray;
    Any suggestions, pointers or solutions would be much appreciated.
    Thanks very much.

    Doing it the "old fashioned" way:
    You need to keep track of a "from index" so you don't search through parts of the string you've already replaced:
           public static void main(String args[]) {          
              try {     
                   String[] lines = new String[] {
                        "the dog went up the dog hill",
                        "all dogs go to dog heaven",
                        "the dogball takes place on 3rd april"
                   lines = replace(lines, "dog", "dog dog");
                   for (int i = 0; i < lines.length; i++) {
                        System.out.println(lines);
              } catch (Exception e) {
                   e.printStackTrace();
         private static String[] replace(String[] lines, String searchWord, String replaceWord) {
              if (searchWord.equals(replaceWord)) return lines; // nothing to do          
              for (int i = 0; i < lines.length; i++) {
                   int fromIndex = 0; // from index to do indexOf
                   String line = lines[i];
                   while (line.indexOf(searchWord, fromIndex) != -1) {
                        final int index = line.indexOf(searchWord, fromIndex);
                        line = line.substring(0, index) + replaceWord + line.substring(index + searchWord.length());
                        fromIndex = (line.substring(0, index) + replaceWord).length();
                   lines[i] = line; // replace
              return lines;

  • Looping through a refcursor to get list of dates as a string

    hi,
    i have a simple procedure which gives me list of from dates and to dates
    i need to get the dates a comma separated dates
    i am not sure if this can be done directly by doing a for loop on the refcursor or i have to fetch it into a record/array and then concatenate with comma or is there anything else that can be done.
    i tried out some stuff like below
    ps help me out
    the procedure that retruns the list of dates is
    CREATE OR REPLACE procedure SALUSER.prm_sp_rpt_payslip_lop_dates(p_empid in int,p_tran_year in int,p_tran_month in integer,o_dates out sys_refcursor)
    as
    begin
    open o_dates for select  to_char(PHL_LOP_FROM,'DD-Mon-YYYY'),to_char(PHL_LOP_TO,'DD-Mon-yyyy')
                     from prm_h_lop
                     where phl_emp_id=p_empid
                       and phl_tran_year=p_tran_year
                       and phl_Tran_month=p_tran_month;
    end;
    /i need my o/p as
    dates :<date1>,<date2>...etcregards,

    Maybe sth. like
    SQL>  var cur refcursor
    SQL>  declare
    cr sys_refcursor;
    procedure prm_sp_rpt_payslip_lop_dates (cr in out sys_refcursor)
    as
    begin
       open cr for select hiredate from emp;
    end prm_sp_rpt_payslip_lop_dates;
    begin
    prm_sp_rpt_payslip_lop_dates(cr);
    open :cur for select 'Dates: ' || column_value dates from xmltable('string-join(//text(), ", ")' passing xmltype(cr));
    end;
    PL/SQL procedure successfully completed.
    SQL>  print cur
    DATES                                                                          
    Dates: 17-Dec-1980, 20-Feb-1981, 22-Feb-1981, 02-Apr-1981, 28-Sep-1981, 01-May-1
    981, 09-Jun-1981, 19-Apr-1987, 17-Nov-1981, 08-Sep-1981, 23-May-1987, 03-Dec-198
    1, 03-Dec-1981, 23-Jan-1982                                                    
    1 row selected.

Maybe you are looking for