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.

Similar Messages

  • Sort up and sort Down push buttons in module pool with table control wizard

    hi,
    i have created 2 buttons for Sort up and sort Down push buttons in module pool with table control wizard
    please any one can help me.
    regards

    Hi
    Following code is to enable and disable the tbl control using two buttons. Just alter the code and for each button write the sort code.
    REPORT  YJAN27_SCREEN                                               .
    TABLES: SFLIGHT, YFLIGHT_28.
    TYPES: BEGIN OF struct1,
          carrid like sflight-carrid,
          connid like sflight-connid,
          fldate like sflight-fldate,
           END OF struct1.
    CONTROLS TBL1 TYPE TABLEVIEW USING SCREEN 2700.
    DATA: OK_CODE LIKE SY-UCOMM,
          CARRID LIKE SFLIGHT-CARRID,                                    "cols in tbl ctrl
          CONNID LIKE SFLIGHT-CONNID,
          FLDATE LIKE SFLIGHT-FLDATE,
          itab TYPE TABLE OF STRUCT1 WITH HEADER LINE,
          cols like line of TBL1-COLS,
          FLAG TYPE I.
    FLAG = 1.
    CALL SCREEN 2700.
    *&      Module  STATUS_2700  OUTPUT
    *       text
    MODULE STATUS_2700 OUTPUT.
      SET PF-STATUS 'BACK'.
    *  SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_2700  OUTPUT
    *&      Module  USER_COMMAND_2700  INPUT
    *       text
    MODULE USER_COMMAND_2700 INPUT.
    OK_CODE = SY-UCOMM.
    CASE OK_CODE.
      WHEN 'BACK'.
        LEAVE PROGRAM.
      WHEN 'DIS'.                                                         "write code for sort up
        loop AT TBL1-COLS INTO COLS.
           COLS-SCREEN-INPUT = 0.
            MODIFY TBL1-COLS FROM COLS.
        ENDLOOP.
        FLAG = 2.
      WHEN 'ENA'.                                                       "write code for sort down
        loop AT TBL1-COLS INTO COLS.
            COLS-SCREEN-INPUT = 1.
            MODIFY TBL1-COLS FROM COLS.
        ENDLOOP.
        FLAG = 1.
    ENDCASE.
    ENDMODULE.                 " USER_COMMAND_2700  INPUT
    *&      Module  GET_DATA  OUTPUT
    *       text
    MODULE GET_DATA OUTPUT.
      select carrid connid fldate from SFLIGHT into table itab.
    ENDMODULE.                 " GET_DATA  OUTPUT
    *&      Module  POPULATE_TBL  OUTPUT
    *       text
    MODULE POPULATE_TBL OUTPUT.
        MOVE-CORRESPONDING ITAB TO SFLIGHT.
    ENDMODULE.                 " POPULATE_TBL  OUTPUT
    *&      Module  CHANGE_SCREEN  OUTPUT
    *       text
    MODULE CHANGE_SCREEN OUTPUT.    " use this module if you want to hide the other button
    CASE FLAG.
      WHEN 1.
        LOOP AT SCREEN.
          IF SCREEN-NAME = 'B_ENA'.
            SCREEN-INVISIBLE = 1.
             MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
        LOOP AT SCREEN.
          IF SCREEN-NAME = 'B_DIS'.
            SCREEN-INVISIBLE = 0.
             MODIFY SCREEN.
          ENDIF.
       ENDLOOP.
      WHEN 2.
        LOOP AT SCREEN.
          IF SCREEN-NAME = 'B_DIS'.
            SCREEN-INVISIBLE = 1.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
        LOOP AT SCREEN.
          IF SCREEN-NAME = 'B_ENA'.
            SCREEN-INVISIBLE = 0.
             MODIFY SCREEN.
          ENDIF.
       ENDLOOP.
    ENDCASE.
    ENDMODULE.                 " CHANGE_SCREEN  OUTPUT
    PROCESS BEFORE OUTPUT.
    MODULE STATUS_2700.
    MODULE CHANGE_SCREEN.     " use this if you want to display one button at a time
    MODULE GET_DATA.
    loop at itab WITH control TBL1.
        MODULE POPULATE_TBL.       " populate tbl ctrl
    endloop.
    PROCESS AFTER INPUT.
    MODULE USER_COMMAND_2700.    " do the sort operations
    loop at itab.
      endloop.
    Hope this helps
    Regards,
    Jayanthi.K

  • Module pool question -table control related

    Hi All,
    I have table control with field mark some input enabled fields in it Now the problem is  when i change the content of one row and select that row then control goes to modue in PAI which is called on ON REQUEST but the changed vaule is not capturing in it only slected row with previous content come in that module . Can u suggest some solution or neccessary setting to be done in attribute of tabe control?
    If possible provide code for it
    Thanks
    Parag

    Hi,
       Please go through the following code below to solve your issue.
    REPORT demo_dynpro_tabcont_loop_at.
    CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.
    DATA: cols LIKE LINE OF flights-cols,
          lines TYPE i.
    DATA: ok_code TYPE sy-ucomm,
          save_ok TYPE sy-ucomm.
    DATA: itab TYPE TABLE OF demo_conn.
    TABLES demo_conn.
    *SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE itab.*
    LOOP AT flights-cols INTO cols WHERE index GT 2.
      cols-screen-input = '0'.
      MODIFY flights-cols FROM cols INDEX sy-tabix.
    ENDLOOP.
    CALL SCREEN 100.
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'SCREEN_100'.
      DESCRIBE TABLE itab LINES lines.
      flights-lines = lines.
    ENDMODULE.
    MODULE cancel INPUT.
      LEAVE PROGRAM.
    ENDMODULE.
    MODULE read_table_control INPUT.
      MODIFY itab FROM demo_conn INDEX flights-current_line.
    ENDMODULE.
    MODULE user_command_0100 INPUT.
      save_ok = ok_code.
      CLEAR ok_code.
      CASE save_ok.
        WHEN 'TOGGLE'.
          LOOP AT flights-cols INTO cols WHERE index GT 2.
            IF  cols-screen-input = '0'.
              cols-screen-input = '1'.
            ELSEIF  cols-screen-input = '1'.
              cols-screen-input = '0'.
            ENDIF.
            MODIFY flights-cols FROM cols INDEX sy-tabix.
          ENDLOOP.
        WHEN 'SORT_UP'.
          READ TABLE flights-cols INTO cols WITH KEY selected = 'X'.
          IF sy-subrc = 0.
            SORT itab STABLE BY (cols-screen-name+10) ASCENDING.
            cols-selected = ' '.
            MODIFY flights-cols FROM cols INDEX sy-tabix.
          ENDIF.
        WHEN 'SORT_DOWN'.
          READ TABLE flights-cols INTO cols WITH KEY selected = 'X'.
          IF sy-subrc = 0.
            SORT itab STABLE BY (cols-screen-name+10) DESCENDING.
            cols-selected = ' '.
            MODIFY flights-cols FROM cols INDEX sy-tabix.
          ENDIF.
        WHEN 'DELETE'.
          READ TABLE flights-cols INTO cols WITH KEY screen-input = '1'.
          IF sy-subrc = 0.
            LOOP AT itab INTO demo_conn WHERE mark = 'X'.
              DELETE itab.
            ENDLOOP.
          ENDIF.
      ENDCASE.
    ENDMODULE.

  • Module Pool Progrmaing Table Control

    Hi Experts,
    I Have Created a Module pool Program, In that I have add a table Control.
    i have write all logic and i have to update to the database also. Now my Requirement is when i am enter the data in the table control in first field after that i press enter it will go to the next field this is my requirement..
    example : in my table control i have 3 fields
    matnr maktx meins
    i have enter the  value of matnr after i press tab button  it will go to the next field like that i need in replacing of tab button i press enter it will go  to the next field.
    Thanks
    Sankar

    Hi ,
    Initialy  you have to set the cursor inside the table control required filed using SET cursor statement inside the PBO , each user interaction in PAI you have to capture the line of table control where cursor is currently set using GET CURSOR and again in PBO SET the cursor for your required filed .
    Regards,
    Ratheesh BS

  • Select-option in module pool  with table Control

    HI,
    How to use the select-option in Module Pool and how Can i use the Table control in it.
    Can any body give me some Clues.
    with rgds
    Ranjith

    Hi ..
    PBO.
    LOOP at <table contriol>
    module --- Inside the module
    DATA: g_uti TYPE REF TO cl_fobu_input_util.
      if rollname <> space.
         CREATE OBJECT g_uti
           EXPORTING typename =rollname.
    *....convert to external pattern
         CALL METHOD g_util->output_convert
           EXPORTING
             field_value_int = p_value                 " This is Tablecontrol-low
           IMPORTING
             field_value_ext = p_value.              " Retrun value for Low
    ENDLOOP.
    lly you have code in PAI
    DATA: g_util_1 TYPE REF TO cl_fobu_input_util.
      if rollname <> space.
         CREATE OBJECT g_util_1
           EXPORTING typename = rollname.
    *....convert to internal pattern
         CALL METHOD g_util_1->input_convert
           EXPORTING
             field_value_ext   = p_value
           IMPORTING
             field_value_int_c = p_value.
    The above code should be written for tablecontrol-high aswell..
    you can also refer: Inlcude LSE16NF10 line no 341 & 434 (SE16n)
    Nag

  • Problem in module pool with table control scrolling

    hi,
    i am using the table control in module pool,in the table control i have radion button for all the rows.
    After i got the data into the table control ,if i select radio button and if i press vertical scroll bar button, that radio button is deselecting,how to solve this issue.
    Please help me.

    Hi
    Generally we don't keep radiobuttons in table control for selecting the records
    We keep check boxes for selecting the records
    Radio button is used to select a single from a group of records and at a time only one is selected, where as checkboxes at a time you can select a single or multiple.
    So use checkboxes and code correctly see the doc for Table control
    syntax:
    CONTROLS .
    if you only want to determine the row of the table control. SY´-SUBRC allows you to check if the cursor is placed in a row of a table control.
    u need to comment the performs of table control fields and write ur own perform statements. And u have to declare the table control fields as separate internal tables.
    Go through this urls.
    www.****************
    www.sap-img.com
    Check the below links.
    http://www.planetsap.com/howdo_a.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dbac5135c111d1829f0000e829fbfe/content.htm
    http://sap.niraj.tripod.com/id25.html
    Reward points if useful
    Regards
    Anji

  • Module Pool with Table Control.

    Hi,
    I have developed two screens .
    in the first screen the user enters the data and press the Next Push button then
    in the second screen it should display data in the table control.
    For that purpose I have written code.
    when the user press Next Button then I wrote like this.
    case ok_code.
       when 'NEXT'.
            CALL SCREEN '9001'.
    ENDCASE.
    AND In the PBO Event of the Screen 9001 I have written a Function Module to Popup the data
    in the table control.
    But the problem is when the user press the Next Button it is displaying table control without
    data. But when the press the Back button and again he press the Next Button then it is displaying.
    So, Where is the Problem ?
    How can I correct it ?
    Bye,
    Satya.

    Hi
    IN PAI
    case ok_code.
    when 'NEXT'.
    select the data into an internal table using the entered fields in the first screen.
    so data is there in ITAB.
    CALL SCREEN '9001'.
    ENDCASE.
    in PBO.
    between loop..
    MOVE the internal table data to the table control fields
    endloop.
    see the help for TC
    syntax:
    CONTROLS .
    if you only want to determine the row of the table control. SY´-SUBRC allows you to check if the cursor is placed in a row of a table control.
    u need to comment the performs of table control fields and write ur own perform statements. And u have to declare the table control fields as separate internal tables.
    Go through this urls.
    www.****************
    www.sap-img.com
    Check the below links.
    http://www.planetsap.com/howdo_a.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dbac5135c111d1829f0000e829fbfe/content.htm
    http://sap.niraj.tripod.com/id25.html
    Reward points for useful Answers
    Regards
    Anji

  • Module pool in table control wizared

    Hi
    I have created in module pool table control wizared created insert and delete rows in output.
    insert the data in table control the colume is not save.
    can u tell me the save the data in table control.
    pls tell me the flow of save button.
    after insert the record how to save the data in table control wizard in module pool.
    can u tell me the save button functionality.
    after save data will add in table.

    Hi Venkat,
    I think you have already posted this query with the subject line "Table control" with the thread below today.
    table control
    Try with the online link we have provided you will learn that way on your own.
    Nobody here will write the whole logic for you.
    Try to put in your efforts.
    Regards
    Abhii
    Edited by: Abhii on Sep 8, 2010 3:13 PM

  • Module pool in table control how to add the data

    Hi
    I have created the table contrl.
    In table control editable rows, when ever i have enter the data than save it will update the data in data base.
    in table control 4 fields like
    sales number,sales director,sales manager,sales hirarchy.
    in three fields or editable
    first field or non editable only for numaric values disply.
    that way i have entered three fields.
    first field automatically reganarate heighest value +1.
    like that automatically reganarate.
    whn ever enter the new vaule
    first field autogenarate remaining i will enter the data.after save it will update the data in database.
    can u tell me logic for this.

    Hi Venkat,
    I think you have already posted this query with the subject line "Table control" with the thread below today.
    table control
    Try with the online link we have provided you will learn that way on your own.
    Nobody here will write the whole logic for you.
    Try to put in your efforts.
    Regards
    Abhii
    Edited by: Abhii on Sep 8, 2010 3:13 PM

  • Module pool in table control

    Hi
    I have created table control.in that editable row can add the new value also created.after adding new value
    in will auto incremented based on sales numer in heighest number + 1 like that u can add.
    after increment update the table in data base.
    can u tell me the after enter the data in table control tall me the 'save' button functionality and it will auto incremented
    based on one field
    for example sales order number.
    great for me
    please tell me

    Hi Venkat,
    I think you have already posted this query with the subject line "Table control" with the thread below today.
    table control
    Try with the online link we have provided you will learn that way on your own.
    Nobody here will write the whole logic for you.
    Try to put in your efforts.
    Regards
    Abhii
    Edited by: Abhii on Sep 8, 2010 3:13 PM

  • Module pool Program table control

    Hi,
        In Module pool programming, table control i have 10 items out of which in the same colum i want to put them in edit mode and certain in disply mode.
    Regards

    Hi,
    You can use loop at screen,
    MODULE passdata OUTPUT.
      READ TABLE it_revision INTO wa_rev INDEX tab_clc-current_line.
      IF sy-subrc = 0.
        LOOP AT SCREEN.
          IF screen-group1 = '111'.      " 111 IS THE GROUP NAME
            screen-input = 1.          " input mode
            screen-active = 1.         " input mode.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ELSE.
        LOOP AT SCREEN.
          IF screen-group1 = '111'.       "GROUP NAME
            screen-input = 0.           " display mode
            screen-active = 1.          " DISPLAY MODE.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDMODULE.                 " PASSDATA  OUTPUT
    Make the group of those field ,that you want in input mode
    Hope it will Solve your problem
    Thanks
    Arun kayal.

  • How to create selections-screens to display PO using module pool program

    All,
    I'm new to module pool programming. Can any one please provide me where to create selections screens to display existing purchase orders using the below selection criteria in thr module pool program.,
    SELECT-OPTIONS : S_LIFNR FOR EKKO-LIFNR,
                     S_BSART FOR EKKO-BSART,
                     S_BUKRS FOR EKKO-BUKRS,
                     S_WERKS FOR EKPO-WERKS OBLIGATORY,
                     S_BEDAT FOR SY-DATUM,
                     S_EINDT FOR EKET-EINDT,
                     S_EBELN FOR EKKO-EBELN,
                     S_MATNR FOR EKPO-MATNR.
    provide me step by step to do this.

    Hi,
    Thanks for the reply can you please let me know.
    How can I create the ranges
    like low and high in the selection.
    Using se51 i was able to do only one i,e
    example I need
    purchase order number----
    f4 -
    f4
    Can please tell me how to do this

  • How to access screen field value in a module pool programming?

    Hi Experts,
       I have create a module pool program SAPMYDLG. It contains two screens 100 and 200.
       The first screen contains Employee_ID field. This field is not a dictionary field.
       In the second screen 200, I want to access the value of Employee_ID field from first screen.
       For this I created a global variable v_empid in TOP include.
       Then in the PAI of the screen 100 I have assigned the screen field value to global variable.
       v_empid = Employee_ID.
       But this gives an error saying " Field  Employee_ID not defined".
       What am I doing wrong? How can I access the screen field value?
    Thanks
    Gopal

    Hi,
    Employee_ID field also must u define in the top include when u define that 100 screen and 200 screen will access.
    regards,
    muralii

  • Problem with increasing input field length in module pool programming.

    Hi All,
    I have created a screen in which i have used table control wizard. In my table control I have an input field. The problem is, this input filed only takes 23 inputs at a time. I need to make this field unfixed. This is an quantity field. I am not understanding why this is happening. Can anybody plz help me in this regard ?
    Thanks in advance.
    Tripod.

    HI Tripod  ,
    YOu can add  Lines to Table control  .
    Add one button  by name ADD LINES  : give func code 'ADD'
    IN PBO  ...
    if it_mat[] is not initial .
        describe table it_mat lines ln  .
        tab_ctrl-lines = ln .
      endif.
    case sy-ucomm .
    when  'ADD' .
          perform add_lines .
    endcase  .
    form add_lines .
      ln  = ln + 1 .
      clear it_mat .
      append initial line to it_mat .
    endform .
    regards
    deepak.

  • How to get center alignment of Input/Output field in Module Pool

    Hi Friends,
    I am using Input/Output field in my Module pool program. Dynamically i am submitting the text to Input/Output field. What i want is i want to display the submitted text as center. By default It is displaying left aligned.
    Thank U in advance.
    Mahender.

    Hi,
    Use syntax "Centered".
    take one variable push into the field
    write w_variable1 to w_variable2 centered.
    next push the varaible to Destination screen input/output Field .
    Make sure the Field the Character Type.
    Prabhud@s

Maybe you are looking for