cancel
Showing results for 
Search instead for 
Did you mean: 

Enter record using table control in custom table.

0 Kudos

I have created two tables(ztable1 abd ztable2),in this ztable1 is item table and ztable2 is header table.Now what I have to do is I have to enter record to this table using table control.I have created table control with wizard in screen menu painter and also created module pool program.Now what I have to do is when I enter records in table control that record should be updated in ztable1 which item table and we have to do same with header table.

one more requirement is that each time sales order no should be generated automatically.capture1.png

next requirement is when I enter customer the address should be display automatically also address fields should be grey out.

Please find my code below and let me know as soon as possible.

*&SPWizard: Data incl. inserted by SP Wizard. DO NOT CHANGE THIS LINE!
INCLUDE ZSALES_ORDER_TOP .
*&SPWizard: Include inserted by SP Wizard. DO NOT CHANGE THIS LINE!
INCLUDE ZSALES_ORDER_PBO .
INCLUDE ZSALES_ORDER_PAI .
INCLUDE ZSALES_ORDER_SUB

TABLES : ZTABLE1,ZTABLE2.

DATA : ITAB TYPE STANDARD TABLE OF ZTABLE1.
DATA : WA TYPE ZTABLE1.

*&SPWIZARD: DECLARATION OF TABLECONTROL 'TABC' ITSELF
CONTROLS: TABC TYPE TABLEVIEW USING SCREEN 0100.

*&SPWIZARD: LINES OF TABLECONTROL 'TABC'
DATA: G_TABC_LINES LIKE SY-LOOPC.

DATA: OK_CODE LIKE SY-UCOMM.

DATA: GV_TOTAL TYPE VBAP-NETWR.

Data: w_item type i,

Fl_flag type c.

*****in pbo

MODULE TABC_CHANGE_TC_ATTR OUTPUT.
DESCRIBE TABLE ITAB LINES TABC-lines.
ENDMODULE.

*&SPWIZARD: OUTPUT MODULE FOR TC 'TABC'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: GET LINES OF TABLECONTROL
MODULE TABC_GET_LINES OUTPUT.
G_TABC_LINES = SY-LOOPC.
ENDMODULE.

*****pai

MODULE TABC_MODIFY INPUT.
MODIFY ITAB
FROM WA
INDEX TABC-CURRENT_LINE.
if sy-subrc <> 0.

append wa to itab.

endif.
ENDMODULE.

*&SPWIZARD: INPUT MODULE FOR TC 'TABC'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: PROCESS USER COMMAND
MODULE TABC_USER_COMMAND INPUT.
OK_CODE = SY-UCOMM.
PERFORM USER_OK_TC USING 'TABC'
'ITAB'
' '
CHANGING OK_CODE.
SY-UCOMM = OK_CODE.

CASE SY-UCOMM.


WHEN 'SAVE'.

LOOP AT ITAB INTO WA.
WA-ZPOSNR = ZTABLE1-ZPOSNR.
WA-ZMATNR = ZTABLE1-ZMATNR.
WA-ZWAERK = ZTABLE1-ZWAERK.
WA-ZMENGE = ZTABLE1-ZMENGE.
WA-ZMEINS = ZTABLE1-ZMEINS.
WA-ZNETWR = ZTABLE1-ZNETWR.

APPEND WA TO ITAB.
CLEAR WA.
ENDLOOP.

IF ITAB IS NOT INITIAL.
MODIFY ZTABLE1 FROM TABLE ITAB.

IF SY-SUBRC = 0.
MESSAGE 'DATA ADDED SUCCESSFULLY.' TYPE 'S'.
ELSE.
MESSAGE 'DATA NOT ADDED' TYPE 'I'.
ENDIF.
ELSE.
MESSAGE 'NO DATA' TYPE 'I'.
ENDIF.

WHEN 'BACK'.
LEAVE TO SCREEN 0.
When Refresh.
FL_FLAG = 'X'.
ENDCASE.
ENDMODULE.

MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'STAT100'.
* SET TITLEBAR 'xxx'.


ENDMODULE.

KatiNonhebel
Advisor
Advisor
0 Kudos

Hi,

Thank you for visiting SAP Community to get answers to your questions. I am here to help you to get the most out of it.

First of all, I recommend that you familiarize yourself with https://community.sap.com/resources/questions-and-answers (if you haven't already), as it provides tips for preparing questions that draw responses from our members.

For example you :

  • Can outline what steps you took to find answers (and why they weren't helpful)
  • Can share screenshots of what you've seen/done
  • Can use a descriptive subject line
  • Should also make sure you're using all the appropriate tags, so the right experts can find your question

The more details you provide, the more likely it is that members will be able to assist you

Should you wish, you can revise your question by selecting Actions, then Edit (although once someone answers your question, you'll lose the ability to edit the question -- but if that happens, you can leave more details in a comment).

Finally, if you're hoping to connect with readers, please consider adding a picture to your profile. Here's how you do it: https://www.youtube.com/watch?v=F5JdUbyjfMA&list=PLpQebylHrdh5s3gwy-h6RtymfDpoz3vDS. By personalizing your profile with a photo of you, you encourage readers to respond.

Good Luck

Kati - SAP Community Moderator

Accepted Solutions (0)

Answers (1)

Answers (1)

johnsonjos16
Participant
0 Kudos

Hi Ranjita,

Since you need the header and item tables to be updated together, best approach will be to have a function module for the same. The FM can have header and item details as the parameter. Your modify table can be inside this FM and you can call the FM to add entries to the table.

For the sales order number to be generated automatically, you can create and use a number range object in SNRO transaction. In the FM call SAP stantard FM get_number_next with the number range object to get next salesorder number.

Disabling input fields is something that is possible in screenpainter