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

Code for insert new line and delete on table control no wizard

Former Member
0 Likes
1,392

Dear All

I have written my program using table control , how do i write code to insert my own button for insert new line in between the captured data in the table control. I'm not using wizard table control.

I have written code to delete one line but its deleting and adding the same line again on the table control.

i have searched on forum and didn't get the answer. Your assistance is appreciated.

Regards

William

1 ACCEPTED SOLUTION
Read only

GauthamV
Active Contributor
0 Likes
1,035

>

> I have written code to delete one line but its deleting and adding the same line again on the table control.

>

Can you post your code, there must be some mistake.

Also you can debug any standard transaction(example add new field in SE11 ztable)

to know how it works during add new line.

Dear All

I have written my program using table control , how do i write code to insert my own button for insert new line in between the captured data in the table control. I'm not using wizard table control.

I have written code to delete one line but its deleting and adding the same line again on the table control.

i have searched on forum and didn't get the answer. Your assistance is appreciated.

Regards

William

6 REPLIES 6
Read only

GauthamV
Active Contributor
0 Likes
1,036

>

> I have written code to delete one line but its deleting and adding the same line again on the table control.

>

Can you post your code, there must be some mistake.

Also you can debug any standard transaction(example add new field in SE11 ztable)

to know how it works during add new line.

Read only

Former Member
0 Likes
1,035

here is my code

PROCESS BEFORE OUTPUT.

MODULE STATUS_0100.

loop at itBOQlinesLT with control TAB_BOQ.

endloop.

MODULE Take.

PROCESS AFTER INPUT.

loop at itBOQlinesLT.

      • MODULE Deletelines.

MODULE modify_lines.

MODULE TAB_BOQ_MARK.

endloop.

MODULE USER_COMMAND_0100E AT EXIT-COMMAND.

MODULE USER_COMMAND_0100.

if code = 'DEL'.

loop at itBOQlinesLT WHERE SEL = 'X'.

        • Setting the flag to make the table control in editable mode after

        • deleting the selected line

            • flg = 'Y'.

        • Confirmation of delete

CALL FUNCTION 'POPUP_TO_CONFIRM'

EXPORTING

TITLEBAR = 'Confirm'

text_question = 'Are you sure to delete this record from the database?'

TEXT_BUTTON_1 = 'Yes'(001)

TEXT_BUTTON_2 = 'No'(002)

IMPORTING

ANSWER = lv_answer.

if lv_answer eq '1'.

        • Updating the database table from the internal table

            • UPDATE ZBOQlines FROM TABLE itBOQlinesLT.

        • Deleting the selected row from the internal table

DELETE itBOQlinesLT WHERE SEL = 'X'.

        • Deleting the selected row from the database table

            • DELETE FROM ZBOQlines WHERE SEL = 'X'.

ENDIF.

endloop.

if sy-subrc = 0.

MESSAGE i000(fb) WITH 'Deleted Successfully'.

endif.

ENDIF.

but on inserting a new line i dont know how to do that in a table control.

Regards

William

Read only

Former Member
0 Likes
1,035

Hi,

First delete the row from internal table and then update database table from your internal table...

u are trying to delete the selected row frm database where sel = X

but i think Sel Field is only in ITAB not in DB....

Read only

Former Member
0 Likes
1,035

Hi,

Use the work area to delete the selected row instead of SEL= 'X'.

DELETE FROM ZBOQlines WHERE field1 = itBOQlines-field1.

This should solve the problem i guess.

To insert the line into the table control just get the index you want to insert and use

INSERT itBOQlines INDEX lv_index.

Regards

Kranthi

Read only

Former Member
0 Likes
1,035

Hi

Im using table control without wizard to enter data as its first point of entry and this data is not yet saved in the tables its still on the table control and user has to insert new row or delete before saving the data in the tables.

Regards

William

Read only

Former Member
0 Likes
1,035

Hi,

In PAI, use the below modify statement so that all the values in table control will be updated to internal table.

When user press save just use Modify statement to update the database from internal table.

Loop at itBOQlines.

MODIFY itBOQlines

FROM itBOQlines

INDEX tb_ctrl-current_line.

Endloop.

On Save,

Modify ZBOQlines from table itBOQLines.

Regards,

Kranthi