Skip to Content
avatar image
-2
Former Member

Restrict input according to the previous value of the field, Module Pool Programming.


I am currently designing a custom screen in Module Pool for For Fleet Management (delivery trucks). The client wants to maintain the history of the Vehicle and the associated Driver. Each time there is a Release/ Receival of Vehicle The Primary keu autoupdates to create a new record

The Vehicle Stataus Field (trans_type) contains 2 values:

1. Release to Driver
2. Receive from Driver.

The user should not be allowed to save Release/ Receive of the same Vehicle twice on any future date.

I tried this select query but the user is allowed to give the same vehicle status with different date, which sould not be allowed. Kindly help in this regard.

When 'SAVE'.

Select *
from ztable
into table it_ztable
where vehicle_ID = ztable-vehicle_ID.

SORT it_ztable by vdate descending.

IF sy-subrc = 0.

Message ' Vehicle already Released/ Received' Type 'E'.

ELSE.

Message : i002 (c5) with ' New Transaction Created'.

Perform GEN_NEXT. " FM for Primary Key Auto generate.

Modify Ztable.

Add comment
10|10000 characters needed characters exceeded

  • There is nothing especially challenging about the requirement and I'm sorry but you need to learn how to program before you start work. (Or someone needs to supervise and guide you until you gain more experience.) The question shows no evidence of troubleshooting. You can use debugger to find why "the user is allowed to give the same vehicle status with different date" and adjust the program accordingly or come back with more specific questions.

    I had to learn module pool programming myself at some point but you'll find 0 questions from me on SCN on this. I simply used the existing SAP programs and documentation. This is what ABAPers do, it's our job.

  • Former Member

    Thanks for the word of advice. Infact, this is better than the answer since you went out of the way and showed me how to think and where to look for when faced with such problems. Sorry if my question was not up to the standard, will try harder to look for the solution in the above mentioned places as per your advice before I post any further questions on SCN.

  • Get RSS Feed

3 Answers

  • Mar 13, 2017 at 07:05 AM

    Use the locking mechanism (ENQUEUE/DEQUEUE).

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 13, 2017 at 07:28 AM
    -2

    Hi,

    Try this,

    TYPES:
    BEGIN OF ty_id,
    NO(10),
    status(10),
    date TYPE DATS,
    flag TYPE c,
    END OF ty_id.

    DATA: it_id TYPE TABLE OF ty_id,
    wa_id LIKE LINE OF it_id,
    it_rec LIKE it_id,
    it_rel LIKE it_id.
    FIELD-SYMBOLS: <fs> LIKE LINE OF it_id.


    PARAMETERS: p_id(10) TYPE C,
    p_stat(10) TYPE c.
    START-OF-SELECTION.
    wa_id-no = '1'.
    wa_id-status = 'REL'.
    wa_id-date = '20170101'.
    APPEND wa_id to it_id.

    wa_id-no = '1'.
    wa_id-status = 'REC'.
    wa_id-date = '20170110'.
    APPEND wa_id to it_id.

    wa_id-no = '2'.
    wa_id-status = 'REL'.
    wa_id-date = '20170110'.
    APPEND wa_id to it_id.
    SORT it_id by no status.
    it_rel[] = it_id[].
    it_rec[] = it_id[].

    DELETE it_rec WHERE status NE 'REC'.
    DELETE it_rel WHERE status NE 'REL'.

    "Logic without releasing vehicle can't be recieved irrespective of date's

    LOOP AT it_rel ASSIGNING <fs>. "Released
    READ TABLE it_rec TRANSPORTING NO FIELDS WITH key no = wa_id-no.
    IF sy-subrc IS INITIAL.
    DELETE it_rel INDEX sy-tabix.
    ENDIF.
    ENDLOOP.

    READ TABLE it_rel TRANSPORTING NO FIELDS WITH KEY no = p_id.
    IF sy-subrc <> 0.
    IF p_stat = 'REC'.
    MESSAGE 'Not Released for choosing Receive Options ' TYPE 'E'.
    ENDIF.
    ELSE.
    IF p_stat = 'REC'.
    MESSAGE 'Already Released only recieved options is available' TYPE 'E'.
    ENDIF.
    ENDIF.

    Hope it helful,

    Regards,

    Ramesh

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 13, 2017 at 06:32 AM
    -3

    hi ,

    irrespective of date check vehicle id , if it already exists in data base throw an error..

    regards,

    vinay.

    Add comment
    10|10000 characters needed characters exceeded