Validação de campos em um Table Control

Boa tarde.
Gostaria de pedir um auxilio .
Tenho uma duvida, na seguinte situação. Estou construindo um programa de Module Pool
Neste programa vai ter um tabstrip, para atualizar duas tabelas Z
Na primeira u201CABAu201D, serão  inseridos os registros da tabela pai e na segunda u201CABAu201D, os registros da tabela
Filho a relação será de 1 para N.
Na tabela filho os campos  chaves serão um identificador próprio , mais o registro chave da tabela pai.
Na segunda a aba para inserir os registros da tabela filho, terei que usar um table Control.
O meu problema é que ao inserir os registros na tabela filho, terei que de forma automática preencher o campo que corresponde a chave da tabela pai. Ou seja o usuário na primeira u201Cabau201D digamos digite o código da tabela pai como 10 ao inserir na table Control um registro o campo correspondente a chave  da tabela pai devera ser preenchido com o valor 10 e não permitir ao usuário efetuar qualquer manutenção neste campo.
Como eu faço isso???
Alguém tem algum exemplo????
Obrigado a todos

Olá, bom dia!
Este é um dessenvolvimento bem específico, talvez por isso ninguem lhe respondeu ainda. Voce já deu uma olhada na seção de Wiki, buscando algum código de exemplo?
Vai alguns links que encontrei:
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/1499ec90-0201-0010-769f-860989655f7e?QuickLink=index&overridelayout=true
http://wiki.sdn.sap.com/wiki/display/sandbox/ModulePoolProgramming
O primeiro link traz um exemplo de como torna um campo ineditavel via codigo. Espero que possa ajudar.
Abraços,
Rodrigo Paisante

Similar Messages

  • How can we do the validation for non visible records in table control.

    Hi Experts,
      I have a table control which displays list of material details. I have a button to upload the material details from excel file to table control directly. I have to validate all the customers which are exist in the table. But my item (Material) table control displays only 5 rows i.e only 5 entries are visible in module pool screen. The validation is done for 5 records only in PAI event, but i need to do validation for rest of the records too (Which are not visible on items table), if validation fails then needs to display error message.
      How can we do the validation for non visible records in table control.
    Regards,
    Bujji

    Hi,
    try validating material before displaying it in table control...'
    Rgds/Abhhi

  • Urgent: Table control validation of defaulted values

    Hi All,
    I have 5 fields in my table control. I have provided a button on the screen, if the user clicks that button, one of the fields( checkbox) is set as 'X'.
    Now , I want to validate the value in this field.
    The issue I have is that it is not going into the CHAIN ENCHAIN module logic to do the validation, if the value is updated through the button, but it performs validation if I update the field manually.
    Please advice.
    Thanks.
    K K

    Try this in the PAI process of screen:
    LOOP AT itab.
        CHAIN.
            FIELD: ...
            MODULE CHECK_MODIFIED ON CHAIN-INPUT.
        ENDCHAIN.                                           
    ENDLOOP.
    Oherwise,you can add the check logic into the flow logic of the button,if the value is not valid,block it.
    Edited by: Liang Zhang on May 28, 2008 4:34 AM

  • Issue On Table Control Validation

    Hi All,
    I Got One requirement that is  " Sales Employee Depo Tour Details ",
    Requirement Is ---> IF One Sales Employee Updates Data Base Table Through  Table Control
    Details Are :
    Emp no: 1234, Depo City : Hyderabad, Starting Date : 25:01:2010 End Date:31:12:9999(Default Date If Emp Gives Blank)
    And Then Saves His Tour Details.
    Like That If Another Employee 2345 Wants To Update His  Depot tour In Same City Between Above Dates Error pop up Message Should Display With "  One Employee Already In This City Want to Change End date Of That Employee ".
    If He Press " Yes "  Button Then That Record Display In Table Control In Change Mode After That
    Emp:2345 Changes His End Date To 31:12:9999 To  some 31:12:2010 And Then He Updates The Employee 1234 Details,
    Then He updates his tour Details Like
    Emp no: 2345, Depot City : Hyderabad, Starting Date : 25:01:2011 End Date:31:12:2011.
    so i done this validation in pai module through chain and enchain and up to pop up display i done the process of validation
    but how to display existing record in table control via include .
    Regards
    Udaya Bhasker Bandi
    Edited by: UDAY123 on Jul 19, 2010 9:10 AM

    u have to add the
    TRANSACTION 'COR2'   | [USING bdc_tab [bdc_options]] .
    in wihich
    OPTIONS FROM opt
    DEFSIZE (Selection as to whether the screens of the called transaction are displayed in the standard screen size.) Values "X" (standard size), " " (current size).
    also you have to handle the 'P+'.
    * Structure to hold Parameter string for runtime of CALL TRANSACTION  *
    DATA :
      fs_opt TYPE ctu_params.
    *& Form SETTINGS
    * This Subroutine sets the default size check box to 'X' & Mode as 'N' *
    *  There are no interface parameters to be passed to this subroutine
    FORM settings .
    * Setting the Default size checkbox to 'X' and Mode as 'N'
      fs_opt-defsize = 'X'.
      FS_OPT-DISMODE = 'N'.
    ENDFORM.                               " FORM RETRIEVE_SUBSECTION...
    After filling your BDC Data.
    CALL TRANSACTION 'COR2'  USING t_bdcdata
                               OPTIONS FROM fs_opt
                              MESSAGES INTO t_messages.
    you can see the below example
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/bdcToUploadIT0585Data
    Regards.

  • Validations on table control (Sum of amount field shuold not cross actual amaount))

    Hi Experts,
                      I want to Provide Validations on Table control with Wizard (it should be like when i enter  percentange  in one column  it will caluculate the amount and show it in another column and the sum of that Amount Should not cross the Actual amount).

    hi Jim,
    In the PAI of the Screen A ...
    when sy-ucomm = 'BACK'.
    Transfer  the values in the table control to an internal table itab.
    in the PBO of Screen B.
    Move the values in itab to table control.
    Thanks,
    Kasiraman R

  • Table control Validation

    I have worked in CT04 transaction. In that if we specify the character type (Eg . Characetr Foramt) & enter the number of characetrs as 3 means in value tab it wont allow as to enter value greater than 3. It wont show any error message but it restrict the cursor(the cursor wont move at all)
    I want to do this kind of validation in my table control.
    I debugged the program also But not able to get it.
    Main program is SAPLCTMV and screen number is 1200.
    The table control field is CAWN-ATWRT.
    Can any one help me to solve this problem.
    Thanks in advance.

    write the code on PAI of ur screen to popup a error message if some condition for a particular field of Table control fails as follows -
    PROCESS AFTER INPUT.
    LOOP AT ITAB2.                "ITAB2 is the table for table control.
        module read_table_control.
      ENDLOOP.
    module read_table_control input.
    if itab1-pernr eq '00000022'.
        message w000(000) with 'Enter other value than 22'.    "this is error message
    else.
        MODIFY itab2 FROM itab1 INDEX tabcontrl-current_line.
    endif.
    endmodule.                 " read_table_control  INPUT

  • Validating Table control

    Hi Experts,
    I'm having a table control and I will enter value in first column.
    Once the value is entered other columns should be filled with data based on the user input in column 1.
    Also I need to do validation for the first column.
    How can i do it???
    thanks...

    hi suba ram........
         in the wddomodifyview method....
         read the table....
         loop it and fillhe other columns...
         it will be automatically displayed i teh other tables.
    ---regards,
       alex b justin

  • Validations when inserting records into database using table control?

    hi , guru's.
          iam inserting records into database table through table control when i press insert i want check which record is existing and which is not . so please give me any sample code
    regards,
    satheesh.

    hi , arjun.
    please check this code.
        WHEN 'INSERT'.
        data: g_vcontrol_itab1 like table of zcust_call_rec,
              g_vcontrol_wa1 like g_vcontrol_wa.
         SELECT *  FROM zcust_call_rec
                   INTO CORRESPONDING FIELDS OF TABLE g_vcontrol_itab1
                   FOR ALL ENTRIES IN g_vcontrol_itab
                   WHERE kunnr = g_vcontrol_itab-kunnr AND budat = g_vcontrol_itab-budat.
            loop at g_vcontrol_itab into g_vcontrol_wa.
               read table g_vcontrol_itab1 into g_vcontrol_wa1
                    with table key  g_vcontrol_wa-kunnr = kunnr and g_vcontrol_wa-budat = budat.
                     if sy-subrc = 0.
                       delete g_vcontrol_itab.
                     endif.
            endloop.
          LOOP AT g_vcontrol_itab INTO g_vcontrol_wa.
            INSERT into zcust_call_rec values g_vcontrol_wa.
          ENDLOOP.
    with this iam getting error message like this.
              <b>g_vcontrol_wa-budat is not expected.</b>

  • How to populate data in table control  .

    hi all,
    i put matnr no. in screen no. 103
    validation is done at that screen only.
    now when i want to modify dat record
    when i put matnr no. at screen 103
    so how i will get all  data of dat number to table control screen.

    Hi Darshan,
       Here is a detailed description of how to update data in table controll.
      Updating data in table control
    The ABAP language provides two mechanisms for loading the table control with data from the internal table and then storing the altered rows of the table control back to the internal table.
    Method 1: Read the internal table into the Table Control in the screenu2019s flow logic.  Used when the names of the Table Control fields are based on fields of the internal table.
    Method 2: Read the internal table into the Table Control in the module pool code. Used when the names of the Table Control fields are based on fields of the database table.
    Method 1 (table control fields = itab fields)
    In the flow logic we can read an internal table using the LOOP statement. Define the reference to the relevant able control by specifying WITH CONTROL <ctrl>
    Determine which table entry is to be read by specifying CURSOR <ctrl>-CURRENT_LINE.
    After the read operation the field contents are placed in the header line of the internal table. If the fields in the table control have the same name as the internal they will be filled automatically. Otherwise we need to write a module to transfer the internal table fields to the screen fields.
    We must reflect any changes the user makes to the fields of the table control in the internal table otherwise they will not appear when the screen is redisplayed after PBO processing, (eg, after the user presses Enter or scrolls) However, this processing should be performed only if changes have actually been made to the screen fields of the table control (hence the use of the ON REQUEST)
    PROCESS BEFORE OUTPUT.
    LOOP AT ITAB_REG WITH CONTROL TCREG
    CURSOR TCREG-CURRENT_LINE.
    ENDLOOP.
    PROCESS AFTER INPUT.
    LOOP AT ITAB_REG.
    MODULE MODIFY_ITAB_REG.
    ENDLOOP.
    MODULE MODIFY_ITAB_REG INPUT.
    MODIFY ITAB_REG INDEX TCREG-CURRENT_LINE.
    ENDMODULE.
    Method 2 (table control fields = dict. fields)
    If using a LOOP statement without an internal table in the flow logic, we must read the data in a PBO module which is called each time the loop is processed.
    Since, in this case, the system cannot determine the number of internal table entries itself, we must use the EXIT FROM STEP-LOOP statement to ensure that no blank lines are displayed in the table control if there are no more corresponding entries in the internal table.
    PROCESS BEFORE OUTPUT.
    LOOP WITH CONTROL TCREG.
    MODULE READ_ITAB_REG.
    ENDLOOP.
    PROCESS AFTER INPUT.
    LOOP WITH CONTROL TCREG.
    CHAIN.
    FIELD: ITAB_REG-REG,
    ITAB_REG-DESC.
    MODULE MODIFY_ITAB_REG
    ON CHAIN-REQUEST.
    ENDCHAIN.
    ENDLOOP.
    MODULE READ_ITAB_REG OUTPUT.
    READ TABLE ITAB_REG INDEX TCREG-CURRENT_LINE.
    IF SY-SUBRC EQ 0.
    MOVE-CORRESPONDING ITAB_REREG TO TCREG.
    ELSE.
    EXIT FROM STEP-LOOP.
    ENDIF.
    ENDMODULE.
    MODULE MODIFY_ITAB_REG INPUT.
    MOVE-CORRESPONDING TCREG TO ITAB_REG.
    MODIFY ITAB_REG INDEX
    TCREG-CURRENT_LINE.
    ENDMODULE.
    Updating the internal table
    Method 1
    PROCESS AFTER INPUT.
    LOOP AT ITAB_REG.
    CHAIN.
    FIELD: ITAB_REG-REG,
    ITAB_REG-DESC.
    MODULE MODIFY_ITAB_REG ON CHAIN-REQUEST.
    ENDCHAIN.
    ENDLOOP.
    MODULE MODIFY_ITAB_REG INPUT.
    ITAB_REG-MARK = u2018Xu2019.
    MODIFY ITAB_REG INDEX TCREG-CURRENT_LINE.
    ENDMODULE.
    Method 2
    PROCESS AFTER INPUT.
    LOOP WITH CONTROL TCREG.
    CHAIN.
    FIELD: TCREG-REG,
    TCREG-DESC.
    MODULE MODIFY_ITAB_REG ON CHAIN-REQUEST.
    ENDCHAIN.
    ENDLOOP.
    MODULE MODIFY_ITAB_REG INPUT.
    MOVE-CORRESPONDING TCREG TO ITAB_REG.
    ITAB_REG-MARK = u2018Xu2019.
    MODIFY ITAB_REG INDEX TCREG-CURRENT_LINE.
    ENDMODULE.
    Updating the database
    MODULE USER_COMMAND_100.
    CASE OK_CODE.
    WHEN u2018SAVEu2019.
    LOOP AT ITAB-REG.
    CHECK ITAB_REG-MARK = u2018Xu2019.
    MOVE-CORRESPONDING ITAB_REG TO TCREG.
    UPDATE TCREG.
    ENDLOOP.
    WHEN u2026
    u2026
    ENDCASE.
    ENDMODULE.
    Hope this will solve your problem.
    Regards,
    Pavan.
    Edited by: PAVAN CHANDRASEKHAR GANTI on Aug 3, 2009 12:48 PM

  • Problem while saveing in Table Control.

    Hi
    I am geting error while saving data in table control.
    This table contol is pop up window at end of screen .
    user enter qty & uom in TC..
    Error i am getting is...
    Field symbol has not been assigned.
    Error analysis                                                                               
    The system tried to access an anasigned field symbol (data segment        
    number 32772).                                                                               
    The field symbol is no longer assigned, because a Unicode program         
    previously tried to set the field symbol using an ASSIGN statement with   
    an offset/length declaration. The memory addressed in this offset/length  
    declaration, however, no longer lay within the valid range.                                                                               
    Information on where terminated                                                                               
    The termination occurred in the ABAP program "SAPLOMCV" in                
    "CONVERSION_EXIT_MATN1_INPUT".                                           
    i Have coded like this..
    MODULE USER_COMMAND_0112 INPUT.
      CASE OKCODE.
        WHEN 'BACK' or 'CANCEL'.
          SET SCREEN 0.
    This iti is contain data which diplay in TC
         when 'DISPLAY'.
              LOOP AT ITI.
              read table iti with key ingr_code = iti-ingr_code
                                      ingr_desc = iti-ingr_desc.
              wka1-ingr_code = iti-ingr_code.
              wka1-ingr_desc = iti-ingr_desc.
              wka1-conc = iti-conc.
              wka1-quantity = iti-quantity.
              wka1-uom = iti-uom.
            append wka1 to itf.
            ENDLOOP.
         WHEN 'SAV'.
          loop at itf where check = 'x' .
                  update zacg_ns
                    set ingr_code = itf-ingr_code
                    col_name = itf-ingr_desc
                    conc = itf-conc
                    quantity = itf-quantity
                      UOM =  itf-UOM
                      ru = itf-ru
                      where ingr_code = itf-ingr_code
                      and col_name = itf-ingr_desc.
        zacg_ns-ingr_code = itf-ingr_code.
       zacg_ns-col_name = itf-ingr_desc.
       zacg_ns-conc = itf-conc.
      zacg_ns-quantity = itf-quantity.
    zacg_ns-UOM = itf-UOM.
    update zacg_ns.
                     endloop.
                     leave program.
                  ENDCASE.
              ENDMODULE.                 " USER_COMMAND_0112  INPUT
    MODULE read_table_control INPUT
    MODULE read_table_control INPUT.
      MODIFY itf  INDEX tc-current_line.
    ENDMODULE.                    "read_table_control INPUT
    *&  Include           ZACG_NS_2                                        *
    *&      Module  STATUS_0111  OUTPUT
          text
    MODULE STATUS_0111 OUTPUT.
      SET PF-STATUS 'ZNEWSHADE'.
      SET TITLEBAR 'ZNS'.
    ENDMODULE.                 " STATUS_0111  OUTPUT
    *&      Module  STATUS_0112  OUTPUT
          text
    MODULE STATUS_0112 OUTPUT.
      SET PF-STATUS 'ZTC'.
    SET TITLEBAR 'xxx'.
      DESCRIBE TABLE itf LINES lines.
      tc-lines = lines.
    ENDMODULE.                 " STATUS_0112  OUTPUt
                                                                                    PROCESS BEFORE OUTPUT.
    MODULE STATUS_0112.
    LOOP at itf WITH CONTROL TC CURSOR tc-current_line.
        MODULE TC_PBO  .
      ENDLOOP.
    PROCESS AFTER INPUT.
      MODULE CANCEL AT EXIT-COMMAND.
    LOOP at itf .
        module read_table_control.
      ENDLOOP.
    MODULE USER_COMMAND_0112.
    Can any one help me..

    Hi,
    Did you enter that filed later after creating the table control?
    You check in the element list whether for that element u have an entry or not..
    Regards,
    Nishant

  • Baffling Table Control

    Hi,
    Currently using SAP 4.7 SAPKB62011
    The need was to develop a program, which based on a selection-criteria displays a table(editable) and some changes will be done in the table and data should get saved.
    The best approach I assumed was to
    a) Create a report, define the selection screen parameters
    b) Do validation in at selection-screen
    c) If all validations are proper, select values to be shown in table control
    d) call screen 9000
    Everything is working perfectly, except for adding new lines in table control.
    When I execute select query in AT SELECTION-SCREEN event before calling the screen 9000, then I am not able to add values to table control.
    But if I put the select query in the PBO of screen 9000, I am able to add new values. Only those values which are already present in table control can be changed. I am not able to add any new entries.
    In my opinion, there should not be a select query in PBO, because that query would hit the database in all possible events.
    Any particular reason, why.
    <b>AT SELECTION-SCREEN code</b>
    AT SELECTION-SCREEN.
      CASE sy-ucomm.
        WHEN 'ONLI'.
          lv_pernr = p_pernr.
          lv_lifnr = p_lifnr.
    *      SELECT *
    *        FROM zpersoninfo
    *        INTO TABLE lt_zpersoninfo
    *       WHERE personno = lv_pernr.
    *      IF sy-subrc <> 0.
    *      ENDIF.
    *      APPEND INITIAL LINE TO LT_ZPERSONINFO.
          CALL SCREEN 9000.
      ENDCASE.
    <b>Dynpro code</b>
    PROCESS BEFORE OUTPUT.
      MODULE pbo_9000.
    LOOP AT lt_zpersoninfo INTO zpersoninfo WITH CONTROL tablecontrol CURSOR
    tablecontrol-current_line.
        MODULE pbo_tc_9000.
      ENDLOOP.
    PROCESS AFTER INPUT.
      LOOP.
        MODULE pai_tc_9000.
      ENDLOOP.
      MODULE pai_9000.
    <b>PBO_9000</b>
    MODULE pbo_9000 OUTPUT.
      SET PF-STATUS lv_pfstatus.
      pa0315-pernr = lv_pernr.
      SELECT *
        FROM zpersoninfo
        INTO TABLE lt_zpersoninfo
       WHERE personno = lv_pernr.
      IF sy-subrc <> 0.
      ENDIF.
      APPEND INITIAL LINE TO LT_ZPERSONINFO.
    ENDMODULE.                 " PBO_9000  OUTPUT
    <b>PBO 9000 - Table Control Code</b>
    MODULE pbo_tc_9000 OUTPUT.
      LOOP AT SCREEN.
        IF lv_pfstatus = 'DISPLAY'.
          CASE screen-name.
            WHEN 'ZPERSONINFO-SERVICENO'.
              screen-input = '1'.
              screen-active = '1'.
            WHEN 'ZPERSONINFO-MANDATORY'.
              screen-input = '1'.
              screen-active = '1'.
          ENDCASE.
        ELSEIF lv_pfstatus = 'CHANGE'.
          CASE screen-name.
            WHEN 'ZPERSONINFO-SERVICENO'.
              screen-input = '0'.
            WHEN 'ZPERSONINFO-MANDATORY'.
              screen-input = '0'.
          ENDCASE.
        ENDIF.
        MODIFY SCREEN.
      ENDLOOP.
    ENDMODULE.
    Let me know if I have skipped some information, which you may find it useful to find the solution.
    Regards,
    Subramanian V.

    That is because I didn't upate the 'LINES' field in tablecontrol. How silly !!
    Regards,
    Subramanian V.

  • Retrieving values from table control using DYNP_VALUES_READ

    Hi all,
    I am trying to retrieve the values from the table control using the FM DYNP_VALUES_READ. I have a situation where user enter values in table control in T.code FB60 in Withholding tab for validation purpose. There i'll have to check based on some entries maintained in SET.
    I am unable to get the values when i scroll to the next page in the table control. FM raising an exception invalid_dynprofield.
    Expecting reply...

    You have to populate the dynpfields internal table before calling the function,
    data: repid like sy-repid.
    dynpfields-fieldname = 'PNAME'.
    append dynpfields.
    repid = sy-repid.
    call function 'DYNP_VALUES_READ'
    exporting
    dyname = repid
    dynumb = sy-dynnr
    tables
    dynpfields = dynpfields
    exceptions
    others.
    read table dynpfields index 1.
    pname = dynpfields-fieldvalue.
    Now you will have the field value in pname
    Hope this helps
    Vinodh Balakrishnan

  • How to validate the dates in the table control ?

    How to validate the dates in the table control ?
    Can I write like this ?
    LOOP AT it_tab .
    CHAIN.
    FIELD : it_tab-strtdat,it_tab-enddat.
    module date_validation.
    ENDCHAIN.
    ENDLOOP.
    Module Date_validation.
    ranges : vdat type sy-datum.
    vdat-sign = 'I'.
    VDAT-LOW = it_tab-STRTDAT.
    VDAT-HIGH = it_tab-ENDDAT.
    VDAT-OPTION = 'BT'.
    APPEND VDAT.
    WHAT CODE I have to write here to validate ?
    and If I write like this How can we know which is the current row being add ?
    It loops total internal table ..?
    Bye,
    Muttu.

    Hi,
    I think there is no need to put chain endchain.
    To do validation you have to write module in PAI which does required validations.
    Thanks
    DARSHAN PATEL

  • Editing one row at a time in a table control

    Good day all
    I need your urgent assistance with the problem below:
    At first time load, the table control needs to allow input on the first line only, validation will then be done through clicking a “check” button.  After the check has been done, table control needs to open up the second row for input and grey out the first one. This sequence needs to follow every time a check has been performed.
    After the check has been done, table control needs to show the previously entered data on the first line but grey it out, and open up only the second row for input.
    The table control has been created using a wizard with an internal table and I am working on dialog/screen programming. The table control has been created as an output control but it needs to perform as both and output and input control.
    I have made changes to the “MODULE tc_create_ph2_get_lines OUTPUT.” Which is created by the wizard as follows:
    The module is in the PBO Section.
    IF it_tab is initial.                                                                 "it_tab being the internal table that stores the data from the table control                        
         DESCRIBE TABLE it_tab LINES lv_num.
               LOOP AT SCREEN.
           IF tc_create_ph2-current_line <> 1.
             screen-input = 0.
             MODIFY SCREEN.
           ENDIF.
         ENDLOOP.
       ELSE.
    tc_create_ph2-current_line = lv_num + 1.
         LOOP AT SCREEN.
           IF tc_create_ph2-current_line <> lv_num + 1 .
             screen-input = 0.
             MODIFY SCREEN.
           ENDIF.
         ENDLOOP.
       ENDIF.
      Your assistance will be highly appreciated.

    Hi Dineo,
    This module would make all line non editable except the last line, which will be open for input.
    LOOP AT IT_ST INTO WA_ST WITH CONTROL MATERIAL CURSOR
    MATERIAL-CURRENT_LINE.
        module mod_screen.
       ENDLOOP.
    module MOD_SCREEN output.
       data : tc_lines type n.
       describe table it_st LINES tc_lines.
    *  loop at screen.
         if material-current_line le tc_lines.
          loop at screen.
           screen-input = 0.
           modify screen.
           endloop.
          endif.
    endmodule.
    When checking and saving data, after saving data delete all lines of tc internal table except the last added row, if you want only the last record to appear in the table.

  • Comparing screen input in program in module pool programming(table control)

    Experts,
    I am a newbie in ABAP. I am working dialog programming where I am replicating PR creation. I am asking user to enter item number, material number and plant. I am validating material number and plant using chain and endchain. This validation is working fine and it throws error message if user enters invalid input. I am able to see corresponding details (corresponding details like unit of measure, delivery date and short text etc. if values entered are correct.) when user clicks on ADD button. Now I have one problem. If user enters same item number twice it should throw error message. I am not able to figure out how it should be done. I thought to set flag = 'X' after user enters item number.
    I am using table control. The validation part for material number(matnr) and plant (werks) work fine. I am getting problem while checking entered item number to check duplication.
    User should not enter the same item number again.
    In my structure i have defined a variable called checkflag(1) type c. and i am doing it now following way. Right now my checkflag code is commented.
    Following is my snippet for the same.
    Please let me know your ideas/suggestions and advices.
    DATA : counter TYPE i,
             itmno1 TYPE i.
      SELECT SINGLE matnr
           FROM mara INTO matno WHERE matnr = it_pr-matnr.
      SELECT SINGLE werks
             FROM t001w INTO plant WHERE werks = it_pr-werks.
      SELECT SINGLE matnr werks
             FROM marc INTO (matno,plant)
        WHERE matnr = it_pr-matnr AND werks = it_pr-werks.
      itmno1 = it_pr-bnfpo.
      IF ok_code = 'ADD'.
        IF it_pr-matnr <> matno OR it_pr-werks <> plant AND it_pr-bnfpo = ''.
          MESSAGE 'Not a Valid material number or plant. Please enter valid values.' TYPE 'E'.
        ELSEIF it_pr-matnr = matno AND it_pr-werks = plant AND it_pr-bnfpo <> ''.
          SELECT SINGLE maktx FROM makt INTO stext WHERE matnr = it_pr-matnr.
          SELECT SINGLE meins FROM mara INTO tmeins WHERE matnr = it_pr-matnr.
          SELECT SINGLE lpein FROM eban INTO tlpein WHERE matnr = it_pr-matnr.
    *      if it_pr-bnfpo = itmno1.
    *        it_pr-checkflag = 'X'.
    *      endif.
          READ TABLE it_pr WITH TABLE KEY
          checkflag = it_pr-checkflag
          bnfpo = it_pr-bnfpo
          maktx = it_pr-maktx
          matnr = it_pr-matnr
          eindt = it_pr-eindt
          meins = it_pr-meins
          werks = it_pr-werks
          lpein = it_pr-lpein.
    *      if it_pr-checkflag = 'X'.
    *          message 'Please enter another item number.' TYPE 'E'.
    *          endif.
          IF sy-subrc <> 0.
            it_pr-bnfpo = itmno1.
            it_pr-maktx = stext.
            it_pr-lpein = tlpein.
            it_pr-meins = tmeins.
            APPEND it_pr.
          ENDIF.
          IF sy-subrc = 0.
            MESSAGE 'Please enter another item number.' TYPE 'E'.
          ENDIF.
        ENDIF.
      ENDIF.

    Indeed thank you very much @medha24 and @gargi sarkar.
    If I use current-line, I will have to skip first entry as first entry should be appended. Then only I would be able to compare it with newly entered value. I will have to use loop end loop within the PAI. I have already written this code in the validation PAI  itself.
    I am not getting how I should use loop endloop effectively so that control will go to the next iteration effectively. Right now with this code, I am getting partial success if I enter item number in bulk (more than one item number as input at same time). later, even though I enter correct values I get error message as it doesn't find next entry in the table. It only appends first records only. Therefore, I am looking to enter first entry without any check and later entries should be compared and appended. I would appreciate your ideas/suggestions.
    Thank you.
    Best reagrds.

Maybe you are looking for

  • Af:statusIndicator does not show busy icon when a command button is click

    Hi Guys, af:statusIndicator does not show busy icon or motion when a command button is click I am working on an excel data upload functionality on .jspx page. I use "af:inputFile" file uploader to upload an excel file then process the data and store

  • Alerts configuration- getting the actual contents of the payload

    Hi    We are on XI 3.0 SP18 - My understanding so far - on alert category definitions has been that - we can create container variables - pull in - system variables as a part of the contents of the alert message - Now , if I want to grab the contents

  • Data connection filter

    Hi, We currently working with a PDF template combined with a data connection to an xsd input file. In the corresponding xml we have the following code: <ListOfCwiWerkzoekendeKnelpunten>   <CwiWerkzoekendeKnelpunten>     <Type>Loonkost</Type>     <Pla

  • Excel chart scale

    I cannot get LabView to set the maximum scale for my chart. Any idea? Thanks Attachments: test_filter_data_macro.vi ‏165 KB

  • HT4859 how to see what is backed up in iclooud

    Hi there, I am quite new to this icloud lark and wondered if there is a way of seeing what is actually stored in icloud.  The last time I had to back up I lost all my photos as I didn't know about putting the photostream on.  I was having problems wi