Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Table control insert Issue

kabil_g
Active Participant
0 Likes
1,356

Hi Frds,

When I Click on inserting one line again ....... When i click on insert option line is selected  and

when i unselect and click insert it's inserting a row ..... My requirement when it's selected also need to insert a new row...

Pls help me out .....below is my piece of code.

IF SY-UCOMM = 'INSERT' .

     LOOP AT GT_COST INTO GW_COST WHERE MARK = 'X'.

       DESCRIBE TABLE GT_COST LINES GV_LINE.

*

*GET CURSOR LINE L_SELLINE.

*&SPWIZARD: GET CURRENT LINE                                           *

       GET CURSOR LINE L_SELLINE.

       IF SY-SUBRC <> 0.                   " append line to table

         L_SELLINE = SOURCE-LINES + 1.

*&SPWIZARD: set top line                                               *

         IF L_SELLINE > GV_LINE.

*        SOURCE-TOP_LINE = L_SELLINE - GV_LINE + 1 .

         ELSE.

           SOURCE-TOP_LINE 1.

         ENDIF.

       ELSE.                               " insert line into table

         L_SELLINE = SOURCE-TOP_LINE + L_SELLINE - 1.

         L_LASTLINE = SOURCE-TOP_LINE + SOURCE-LINES - 1.

       ENDIF.

*&SPWIZARD: set new cursor line                                        *

       L_LINE = L_SELLINE - SOURCE-TOP_LINE + 1.

*&SPWIZARD: insert initial line                                        *

       INSERT INITIAL LINE INTO GT_COST INDEX L_SELLINE.

       SOURCE-LINES = SOURCE-LINES + 1.

*&SPWIZARD: set cursor                                                 *

       SET CURSOR LINE L_LINE.

     ENDLOOP.

ENDIF.

1 ACCEPTED SOLUTION
Read only

VenkatRamesh_V
Active Contributor
0 Likes
1,313

Hi Kabil,

Try,

AT PAI.

LOOP AT IT_VENDOR.

     CHAIN.

       FIELD WA_VENDOR-VENDOR MODULE Vendorname ON CHAIN-REQUEST.

       FIELD WA_VENDOR-NAME1.

       FIELD WA_VENDOR-GSBER.

       FIELD WA_VENDOR-DMBTR MODULE CALC." on CHAIN-reQUEST.

       MODULE TBC_100_MODIFY ON CHAIN-REQUEST.

     endchain.

     FIELD WA_VENDOR-SEL

       MODULE TBC_100_MARK ON REQUEST.

   ENDLOOP.

MODULE TBC_100_MARK INPUT.

" Add logic to insert the line in internal table.

ENDMODULE.

Hope it helpful,

Regards,

Venkat.

11 REPLIES 11
Read only

VenkatRamesh_V
Active Contributor
0 Likes
1,314

Hi Kabil,

Try,

AT PAI.

LOOP AT IT_VENDOR.

     CHAIN.

       FIELD WA_VENDOR-VENDOR MODULE Vendorname ON CHAIN-REQUEST.

       FIELD WA_VENDOR-NAME1.

       FIELD WA_VENDOR-GSBER.

       FIELD WA_VENDOR-DMBTR MODULE CALC." on CHAIN-reQUEST.

       MODULE TBC_100_MODIFY ON CHAIN-REQUEST.

     endchain.

     FIELD WA_VENDOR-SEL

       MODULE TBC_100_MARK ON REQUEST.

   ENDLOOP.

MODULE TBC_100_MARK INPUT.

" Add logic to insert the line in internal table.

ENDMODULE.

Hope it helpful,

Regards,

Venkat.

Read only

0 Likes
1,313

Hi Venkat,

As you mentioned only i have written my code... Inside insert functionality my piece of code given....if there any changes in that.... Pls do let me know.

Kabil.

Read only

0 Likes
1,313

Hi Kabil,

How i understand your requirement.

Want to insert  the line while selecting the line without selecting icon.

Inside PAI.

Try,

MODULE TBC_100_MARK INPUT.

INSERT INITIAL LINE INTO <internal_table> INDEX <n>.  " Below the selected line or above using index no

OR

APPEND INITIAL LINE TO <internal_table>                         "Adding intial lines at last .

ENDMODULE.

Hope it helpful,

Regards,

Venkat.

Read only

0 Likes
1,313

Hi Venkat,

My requirement is when i click on insert one line inserting .... Again if i click on insert line is in selected and i unselect that and again i select and click on insert inserting a new row.................

How many times i click on insert it has to insert a new row,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

Kabil

Read only

0 Likes
1,313

Hi Kabil,

In GET CURSOR LINE L_SELLINE value is filled only when user select's.


Try,

FIELD-SYMBOLS: <val> TYPE ANY,

                             <fs>  type any.

GET CURSOR LINE L_SELLINE.

IF SY-SUBRC <> 0.

LOOP AT <table> ASSIGNING <fs>.

ASSIGN COMPONENT  'SEL' OF STRUCTURE <fs> To <val>.

IF  <val> IS ASSIGNED.

CHECK <val> IS NOT INITIAL.   

L_SELLINE   = sy-tabix.

EXIT.

ENDIF.

ENDLOOP.

*&SPWIZARD: set top line                                               *

     IF L_SELLINE > <LINES>.

       <TC>-TOP_LINE = L_SELLINE - <LINES> + 1 .

     ELSE.

       <TC>-TOP_LINE = 1.

     ENDIF.

   ELSE.                               " insert line into table

     L_SELLINE = <TC>-TOP_LINE + L_SELLINE - 1.

     L_LASTLINE = <TC>-TOP_LINE + <LINES> - 1.



Hope it helpful,


Regards,

Venkat.




Read only

0 Likes
1,313

Hi Venkatesh,

Sorry for the delay reply.

It's working ....Facing here when scrolling it's creating a sytem itself inserting a new row.......

Kabil

Read only

0 Likes
1,313

Hi Kabil,

'

Hope you are using table control wizard, normally  your modified code will not work.

MODULE TABLE_2_USER_COMMAND.

DATA: l_ok              TYPE sy-ucomm,

        l_offset          TYPE i.

*&SPWIZARD: END OF LOCAL DATA------------------------------------------*

*&SPWIZARD: Table control specific operations                          *

*&SPWIZARD: evaluate TC name and operations                            *

  SEARCH p_ok FOR p_tc_name.

  IF sy-subrc <> 0.

    EXIT.             " this statment will not proceed further

  ENDIF.

Kindly debug it.

Regards,

Venkat.

Read only

0 Likes
1,313

Hi Venkat,

I am using normal table control method . not table control with wizard method.

kabil.

Read only

0 Likes
1,313

Debug your code when scrolling.

The code where you are inserting a line is getting called again , which you need to restrict to a specific call.

Hope this helps.

Read only

0 Likes
1,313

Hi Kabli,

Validate your code using Sy-ucomm.

CASE sy-ucomm.

WHEN 'INSERT'.

"Logic to insert the line.

ENDCASE.

Kindly Debug the code.

Hope it helpful,

Regards,

Venkat.

Read only

0 Likes
1,313

Hi Venkat,

Solved the issue Thanks . Ok_code clearing problem..........

Regards,

Kabil