Regarding ABAP code to search city & replace it by corrected city name

Hi,
I have  city master data which has length 18 char
I am using 2 other master data to read city & populate other fields.
Now the problem is the other 2 Master data are of length 13
city comes as truncated & the matching condition fails.
now i need to write a program which will read city master data of 18 char
then it will search pattern in other 2 masted data & populate a table or generate file
with truncated city name & actual 18 char city name.
I tried using CP i.e. Contains Pattern & CS i.e. Contains String but both are not working as per the requirement, even the combination is not working of both of them.
Scenario:
example
city master data has
CITY OF ALLAHABAD
other 2 master data may contain
CITY OF ALHBD
Now I want output as
Sr no      state        wrong city name            corrected city name
1             UP            CITY OF ALHBD            CITY OF ALLAHABAD
Please help me out with implementing the logic.
Thanks & Regards,
Rashmi.

hi,
Rashmi,
Please try
Reads 18 char long city from Correct City sources
Stores in file as corrected city
Then trims the city name to 13 char long & stores in truncated city
Counter is initialized to 1 which increments by 1 each time loop passes
Hope this helps.
Thanks
Mukesh
Edited by: Mukesh Sharma on Aug 5, 2009 12:41 AM

Similar Messages

  • REGARDING ABAP CODE IN ECATT

    HI
       HOW TO WRITE ABAP CODE IN ECATT TESTING FOR IF VENDORNO DOES NOT EXIST IT SHOULD NOT DISPLAY THE VENDOR SCREEN.
            PLZ HELP ME I WILL BE THANKFUL

    I wouldn't use ABAP for this (always remember that using inline ABAP reduces the readability of your script).
    Instead, I would use the corresponding display transaction to attempt to display the vendor and use the MESSAGE...ENDMESSAGE construction in eCATT to catch any error messages that occur. With the MESSAGE command, you can specify that certain error messages - if they occur - should not cause the script to fail.

  • Regarding Abap code in BW

    Hi Sapmates,
    Are any one in Bangalore teaching Abap with BW specific. please kindly let me know. points will be assigned for all help full answers.
    Regards
    Sujan

    Hi Siva ,
    if u want to take any training good institutes r in Hyderabad.

  • Change Prg name in classes using abap code

    Hello Experts,
    I'm having following req:-
    I need to change program name using abap code .
    I have prepared report which changing prg name & also it is replecting target name into T-code & Programes where source prg name is being used.
    My next req is i want to replace sorce prg name in Classes usinf abap coding.
    <Priority normalized by moderator>
    Thanxs in Advance.
    Moderator message : Requirements dumping not allowed, thread locked.
    Edited by: Vinod Kumar on Feb 7, 2012 12:32 PM

    The application name is not necessarily uniqueue! Customers may create two applications with same name in different systems/clients and transport them into the same target system/client!
    You do the mapping with the query:
    CL_FDT_FACTORY=>GET_INSTANCE( )->GET_QUERY()->...
    There are two methods. One for mapping ID to name and one for name to ID.
    There is also a sample report in package SFDT_DEMO_OBJECTS.

  • Trigger Process chain using ABAP code

    Hi All,
    As per my knowledge there are 2 ways to trigger a process chain using ABAP code :
    1) Using FM ‘RSPC_API_CHAIN_START’ and passing process chain name as the parameter
    2)Using FM 'BP_EVENT_RAISE' and passing process event as the parameter, which you can create using SM62 transaction.
    I would like to know which one is better to use, in terms of advantage and disadvantage.
    Thanks,
    Praveena

    Hi praveena,
    check these links ..u .may get some help
    Process Chain
    Process Chain
    How to run a Process Chain
    Process chain-parallel process
    Regards
    BILL

  • Abap code to replace the bank values of Date Field with 20990101

    Please correct my abap code I am just trying to replace the bank values of Dataefield to 20990101 but i am getting the error invalid dataformat '00000000 '. Please correct my IF statement so that I can get this resolved
    IF    SOURCE_FIELDS-DATETO = '00000000 '
          RESULT = '20990101'.
    ENDIF.
    Thanks'
    Soniya

    Hi Soniya,
    You can use one of the following:
    IF SOURCE_FIELDS-DATETO =  ' '.
    RESULT = '20990101'.
    ENDIF.
    or
    IF SOURCE_FIELDS-DATETO IS INITIAL.
    RESULT = '20990101'.
    ENDIF.
    or
    IF SOURCE_FIELDS-DATETO = '00000000'.
    " THERE WAS A SPACE IN YOUR CODE.
    RESULT = '20990101'.
    ENDIF.
    Regards,
    Satya

  • Abap code :replace the bank values of Dataefield to 20990101

    Please correct my abap code I am just trying to replace the bank values of Dataefield to 20990101 but i am getting the error invalid dataformat '00000000 '. Please correct my IF statement so that I can get this resolved
    IF SOURCE_FIELDS-DATETO = '00000000 '
    RESULT = '20990101'.
    ENDIF.
    Thanks'
    Soniya

    Hi ,
    take the Result should be date data type.
    Data : Dateto type sy-datum,
              Result type sy-datum.
    IF SOURCE_FIELDS-DATETO = '00000000 '
    RESULT = '20990101'.
    EndIF.
    I hope it resolved.
    If helpful , plz rewards it.
    Regards,
    Vishvesh.

  • Search and Replace DQXI Transform for Status Codes

    I've been tasked with creating a Search and Replace transform to convert DPV status codes into the textual equivalents.  For example, a status code of "S20000" would convert to "A different city was assigned."
    There are over 200 possible combinations, so I'd like to know if someone else has done this, and would be willing to share their code.

    You could store all your patterns in a Map. Then iterate over the map inserting the patterns into a regex.

  • Help regarding calling BRFPLUS function through ABAP code

    Hi,
          I have  a situation where I have to input  data into a BRFPLUS function  as a table (i.e the data is input as select options where list or range of data can be provided).The corresponding output is also in the form a table .I've created this function in BRFPLUS and is working fine .Now I have to call it through ABAP code.Can someone kindly  provide me with the probable code for this scenario.
    E.g:
            ZT_MATNR  is the table in brfplus representing the list of MATNR values input along with other such inputs to function module Z_FM
            ZT_ATM   is the  resultant output table  of the function  which contains several fields.
    Now I have to call this BRFPLUS function with help of ABAP code.Could someone kindly help.

    Hello ,
    There should be a number of BRF+ tutorials available in SCN which discuss the FDT APIs. You can have a look at them to get an idea of the various APIs available and their uses.
    For your usecase, you should do the following.
            lo_fdt_function         TYPE REF TO if_fdt_function,
            lo_fdt_result           TYPE REF TO if_fdt_result,
    * Get function handle
          CALL METHOD lo_fdt_factory->get_function
            EXPORTING
              iv_id       = lv_function_id
            RECEIVING
              ro_function = lo_fdt_function.
    where lv_function_id is the GUID of the BRF+ function . You can either make it a constant , or you can use a FDT API to get the function GUID from the BRF+ application name and function name.
    *   Set function context
        TRY.
            CALL METHOD lo_fdt_context->set_value
              EXPORTING
                iv_id    =
                ia_value =
    This is one way to set the input context ( pass the input to the BRF+ function to process ). There are other ways to do this as well. Which one you use would depend on the kind of input you want to pass.
    * Execute BRFPLUS function
      TRY.
          CALL METHOD lo_fdt_function->process
            EXPORTING
              io_context = lo_fdt_context
            IMPORTING
              eo_result  = lo_fdt_result.
    * Get result output
      TRY.
          CALL METHOD lo_fdt_result->get_value
            IMPORTING
              ea_value =
    Another direct way of doing it would be to use the method PROCESS of the class CL_FDT_FUNCTION_PROCESS.
    I have not gone into much explaination here , but it should provide you an idea of how you can go about it.Read the SCN docs on the APIs to get a better idea , or better still if you can get hold of a copy of the BRF+ book by Carsten Ziegler , you will get an end to end explaination of all BRF+ APIs in it.
    Regards,
    Indranil.

  • Regarding Customer exit - ABAP Code

    Hi Friends,
    I have a scenario in one of the query and need to write a customer exit for the same. Here is the scenario:
    I am using one input variable XXX to get input from user which feeds value to one of the charateristic lets say "CHAR1" in query. I have one more characteristic "CHAR2" which has to get the value from the same variable XXX. This is not allowed in BI7.0 as the variable is Hierarchy Node type. It gives error that "Variable XXX is used for two different characteristics."
    So i need to create one more vaiable YYY which will get the value from XXX and then YYY will feed value to CHAR2. I would appreciate if some one could tell me step by step how to write customer exit and give me the piece of ABAP code i need to write in my case.
    Your help will be appreciated in terms of points.
    Thanks,

    Hi Manmit,
    The following link can guide you on how to write customer exits (this has example as well)
    [http://help.sap.com/saphelp_nw70/helpdata/EN/61/579b3c494d8e15e10000000a114084/frameset.htm]
    Hope this helps.
    Cheers,
    Sumit

  • ABAP Code To Authenticate Users

    Hi,
    How can I code a ABAP program/function which will authenticate a user based only on their user id?  Do not want to use their password.
    I want the entire authentication process to happen in the ABAP code.
    Any ideas?
    Thanks,
    Audrey

    Hi,
    To check the authorization of the user of an ABAP program, use the AUTHORITY-CHECK statement:
    AUTHORITY-CHECK OBJECT '<object>'
                            ID '<name1>' FIELD <f1>
                            ID '<name2>' FIELD <f2>
                            ID '<name10>' FIELD <f10>.
    <object> is the name of the object that you want to check. You must list the names (<name1>, <name2> ...) of all authorization fields that occur in <object>. You can enter the values <f 1 >, <f 2 >.... for which the authorization is to be checked either as variables or as literals. The AUTHORITY-CHECK statement checks the user’s profile for the listed object, to see whether the user has authorization for all values of <f>. Then, and only then, is SY-SUBRC set to 0. You can avoid checking a field by replacing FIELD <f> with DUMMY. You can only evaluate the result of the authorization check by checking the contents of SY-SUBRC. For a list of the possible return values and further information, see the keyword documentation for the AUTHORITY-CHECK statement. For further general information about the SAP authorization concept, refer to Users and Authorizations.
    There is an authorization object called F_SPFLI. It contains the fields ACTVT, NAME, and CITY.
    SELECT * FROM SPFLI.
       AUTHORITY-CHECK OBJECT 'F_SPFLI'
                            ID 'ACTVT'  FIELD '02'
                            ID 'NAME' FIELD SPFLI-CARRID
                            ID 'CITY'   DUMMY.
       IF SY-SUBRC NE 0. EXIT. ENDIF.
    ENDSELECT.
    If the user has the following authorizations for F_SPFLI:
    ACTVT 01-03, NAME AA-LH, CITY none,
    and the value of SPFLI-CARRID is not between "AA" and "LH", the authorization check terminates the SELECT loop.
    Hope it helps u.
    Thanks&Regards,
    Ruthra.R

  • Schedule a background job for a program using ABAP code.

    Hi,
    I have to write a program to schedule a background job for another program.
    Need your help to understand how we can achieve this functionality.Any example of an abap code would be of great help.
    Need it urgently.
    Thanks in advance.
    Sandeep.

    Hi Sandeep,
    Here is the demo program regarding the BDC For the background job.
    report zprprbdc1
           no standard page heading line-size 255.
    include bdcrecx1.
    parameters: dataset(132) lower case.
    ***    DO NOT CHANGE - the generated data section - DO NOT CHANGE    ***
    *   If it is nessesary to change the data section use the rules:
    *   1.) Each definition of a field exists of two lines
    *   2.) The first line shows exactly the comment
    *       '* data element: ' followed with the data element
    *       which describes the field.
    *       If you don't have a data element use the
    *       comment without a data element name
    *   3.) The second line shows the fieldname of the
    *       structure, the fieldname must consist of
    *       a fieldname and optional the character '_' and
    *       three numbers and the field length in brackets
    *   4.) Each field must be type C.
    *** Generated data section with specific formatting - DO NOT CHANGE  ***
    ***data: begin of itab occurs 0 ,
    ***       matnr(20) type c,
    ***       mbrsh(30) type c,
    ***       mtart(30) type c,
    ***       kzsel(20) type c,
    ***       maktx(40) type c,
    ***       meins(5) type c,
    ***       end of itab.
    data: begin of record occurs 0,
    * data element: MATNR
            matnr_001(018),
    * data element: MBRSH
            mbrsh_002(001),
    * data element: MTART
            mtart_003(004),
    * data element: XFELD
            kzsel_01_004(001),
    * data element: MAKTX
            maktx_005(040),
    * data element: MEINS
            meins_006(003),
    * data element: MTPOS_MARA
            mtpos_mara_007(004),
          end of record.
    *** End generated data section ***
    start-of-selection.
    *perform open_dataset using dataset.
    perform open_group.
    **do.
    **read dataset dataset into record.
    **if sy-subrc <> 0. exit. endif.
    call function 'GUI_UPLOAD'
      exporting
        filename                      = 'c:\jitu\bdc\10002.txt'
       filetype                      = 'ASC'
       has_field_separator           = 'x'
    *   HEADER_LENGTH                 = 0
    *   READ_BY_LINE                  = 'X'
    *   DAT_MODE                      = ' '
    *   CODEPAGE                      = ' '
    *   IGNORE_CERR                   = ABAP_TRUE
    *   REPLACEMENT                   = '#'
    *   CHECK_BOM                     = ' '
    *   VIRUS_SCAN_PROFILE            =
    *   NO_AUTH_CHECK                 = ' '
    * IMPORTING
    *   FILELENGTH                    =
    *   HEADER                        =
      tables
        data_tab                      = record
    * EXCEPTIONS
    *   FILE_OPEN_ERROR               = 1
    *   FILE_READ_ERROR               = 2
    *   NO_BATCH                      = 3
    *   GUI_REFUSE_FILETRANSFER       = 4
    *   INVALID_TYPE                  = 5
    *   NO_AUTHORITY                  = 6
    *   UNKNOWN_ERROR                 = 7
    *   BAD_DATA_FORMAT               = 8
    *   HEADER_NOT_ALLOWED            = 9
    *   SEPARATOR_NOT_ALLOWED         = 10
    *   HEADER_TOO_LONG               = 11
    *   UNKNOWN_DP_ERROR              = 12
    *   ACCESS_DENIED                 = 13
    *   DP_OUT_OF_MEMORY              = 14
    *   DISK_FULL                     = 15
    *   DP_TIMEOUT                    = 16
    *   OTHERS                        = 17
    if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    loop at record .
    perform bdc_dynpro      using 'SAPLMGMM' '0060'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RMMG1-MATNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'RMMG1-MATNR'
                                  record-matnr_001.
    perform bdc_field       using 'RMMG1-MBRSH'
                                  record-mbrsh_002.
    perform bdc_field       using 'RMMG1-MTART'
                                  record-mtart_003.
    perform bdc_dynpro      using 'SAPLMGMM' '0070'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MSICHTAUSW-DYTXT(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform bdc_field       using 'MSICHTAUSW-KZSEL(01)'
                                  record-kzsel_01_004.
    perform bdc_dynpro      using 'SAPLMGMM' '4004'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=BU'.
    perform bdc_field       using 'MAKT-MAKTX'
                                  record-maktx_005.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MARA-MEINS'.
    perform bdc_field       using 'MARA-MEINS'
                                  record-meins_006.
    perform bdc_field       using 'MARA-MTPOS_MARA'
                                  record-mtpos_mara_007.
    perform bdc_transaction using 'MM01'.
    **enddo.
    endloop.
    perform close_group.
    *perform close_dataset using dataset.
    &*****************Reward point if helpful************&

  • Sequence of ABAP code and events.

    Hello,
      Please tell me the proper sequence of writing ABAP code.
    (Event execution sequence and code writing sequence.)
    - which event should follow which event?
    - which code should be written where?
    - Sequence of Includes (e.g. TOP, PBO, PAI, Subroutine,etc.)
    Regards,
    Sharayu.

    Sequence of Includes:
    TOp Include  (All data declarations/Selection screen declared here)
    Form Include ( All subroutines are placed inside it)
    For a Screen
    PBO
    PAI
    Load of program:When the program is executed
    INITIALIZATION: Fill the default values into the fields or we can assign values to the fields in this event. It triggers first.
    AT SELECTION-SCREEN: It is commonly used for validations like ON-REQUEST ( for search help) , OUTPUT ( modify screens ).
    TOP-OF-PAGE: Header of the report or any data to print on top of the page in list.
    END-OF-PAGE: Footer details like page no: / total no: of pages.
    START-OF-SELECTION: For processing ur code selects, loops, FM'S and all.
    END-OF-SELECTION: Output formating. It is not required to write normally but in some special conditions like to print after the START-OF-SELECTION event.

  • RE: (forte-users) search and replace within aTextData

    Welll, you're both right. The MoveToChar makes it unnecessary (if a little
    sloppy) to MoveNext as long as you've changed the character. thus,
    outStr: TextData = new;
    outStr.SetValue(inStr);
    while (outStr.MoveToChar(' ')) do
    outStr.ReplaceRange('_', outStr.Offset, outStr.Offset+1);
    end while;
    return outStr;
    works fine to change blanks to underscores.
    Regards,
    David
    -----Original Message-----
    From: Campbell, Dave [mailto:DCampbellpurolator.com]
    Sent: Friday, 14 January 2000 0:58
    To: 'Matthew Middleton'
    Cc: kamranaminyahoo.com
    Subject: RE: (forte-users) search and replace within a TextData
    If you do not use the MoveNext method to skip beyond the "found" character,
    a subsequent invocation of MoveToChar will find the same character, located
    at exactly the same offset.
    If there is no match, MoveToChar returns FALSE and the current offset does
    not change.
    ----- Original Message -----
    From: Matthew Middleton <mathew.middletonlawpoint.com.au>
    To:kamranaminyahoo.com
    Unless I'm missing something here...you needn't go through every
    character...use MoveToChar()...as per Help...
    while (TextdataObj.MoveToChar (' ')) do
    end while;
    Regards,
    Dave Campbell
    Consultant,
    Caro Systems Inc.
    Mailto:Dave.CampbellCaroSys.com
    For the archives, go to: http://lists.sageit.com/forte-users and use
    the login: forte and the password: archive. To unsubscribe, send in a new
    email the word: 'Unsubscribe' to: forte-users-requestlists.sageit.com

    Why not this:
    while myText.moveToString(' ') do
    myText.ReplaceRange('-', myText.Offset, myText.Offset+1);
    end while;
    or if you prefer verbosity:
    while myText.moveToString(source=' ') do
    myText.ReplaceRange(source='-', startOffset=myText.Offset,
    endOffset=myText.Offset+1);
    end while;
    -----Original Message-----
    From: FatchJeBAM.com [mailto:FatchJeBAM.com]
    Sent: Wednesday, January 12, 2000 2:51 PM
    To: Troy.Burnsvacationclub.com; kamranaminyahoo.com
    Subject: RE: (forte-users) search and replace within a TextData
    How about this?? May have to play with start/end on ReplaceRange as I
    didn't really test this
    Anybody got a better way??
    -- replace space with underscore
    For x in 1 to myTextdata.LengthToEnd() do
    If myTextData.IsSpace() then
    MyTextdata.ReplaceRange('_'. Startoffset=myTextdata.offset,
    endoffset=myTextdata.offset+1);
    End if;
    MyTextdata.MoveNext;
    End for;
    Jerry Fatcheric
    -----Original Message-----
    From: Burns, Troy [mailto:Troy.Burnsvacationclub.com]
    Sent: Wednesday, January 12, 2000 9:40 AM
    To: kamranaminyahoo.com
    Subject: (forte-users) search and replace within a
    TextData
    Hello all,
    I need to search within a textdata object, replacing all
    occurrances of a
    space
    with another character. Can you give a quick code example
    of how I would do
    this?
    Thanks in advance,
    Troy
    Troy Burns
    Marriott Vacation Club Intl.
    E-mail: troy.burnsvacationclub.com
    Phone: (941) 688-7700 ext. 4408
    For the archives, go to: http://lists.sageit.com/forte-users
    and use
    the login: forte and the password: archive. To unsubscribe,
    send in a new
    email the word: 'Unsubscribe' to:
    forte-users-requestlists.sageit.com
    For the archives, go to: http://lists.sageit.com/forte-users and use
    the login: forte and the password: archive. To unsubscribe, send in a new
    email the word: 'Unsubscribe' to: forte-users-requestlists.sageit.com

  • Need ABAP code to make unique hierarchy values - Request prompt help

    hi
    <removed>
    I am new to SAP. Please help me in the following
    I require an ABAP code for the following scenario
    I have a simple hieraarchy. The hierarchy is
    SEG -> fam -> clas -> comm
    The values of the seg , fam, cla, com......all will be charecter values
    But in some cases the values will be NOT_KNOWN
    If the values are NOT_KNOWN i need to change them as NOT_KNOWN_1, NOT_KNOWN_2...like that unique charecter values
    should be replaced for NOT_KNOWN
    Example
    SEG->FAM->CLA ->COM
    Clothing -> Mens wear -> Designer garments -> NOT_KNOWN
    Construction -> equipments -> machinery->NOT_KNOWN
    Computers -> Laptops -> Imported -> NOT_KNOWN
                     -> desktops ->flat monitors -> Indian
                           -> imported                     -> NOT_KNOWN->
    NOT_KNOWN -> baggages
    This should be changed to
    SEG->FAM->CLA ->COM
    Clothing -> Mens wear -> Designer garments -> NOT_KNOWN_1
    Construction -> equipments -> machinery->NOT_KNOWN_2
    Computers -> Laptops -> Imported -> NOT_KNOWN_3
              -> desktops ->flat monitors -> Indian
                              -> imported                         
           -> NOT_KNOWN_4 ->
    NOT_KNOWN_5 -> baggages
    This is to make them unique nodes to upload them in hiereachy
    Data is coming from database tables and i was not supposed to do anything in database and the incomin
    data needs to finetuned like this to update them in cube
    So I like to have some coding which will enable this to work in the start routine
    If start routine is not the right option, where else we can do coding
    <removed>
    Regards
    KC

    data : w_suff_n(8) type n,
             w_suff_c(8).
    loop at data_package.
    if data_package-<fieldval> = 'NOT_KNOWN'.
      w_suff_n = w_suff_n + 1. w_suff_c = w_suff_n.
      shift w_suff_c left deleting leading '0'.
      concatenate data_package-<fieldval> w_suff_c into data_package-<fieldval>.
      modify data_package.
    endif.
    endloop.
    *Change <fieldval> in the above to the actual field name.

Maybe you are looking for