cancel
Showing results for 
Search instead for 
Did you mean: 

Contract Number generation program.

01-11-2011 9:26 AM
638 views 6 comments Go to solution
0 Likes
SAP Managed Tags
Subscribe

Dear All,

I am generating my contract number with the help of Number range object created in SNRO, and by using function

module 'Number Get Next' and am calling that object, now using update table query , I am saving it in Ztable,for only

one material code, but i want same contract number to be generate for multiple material codes, So my Ztable should

have multiple rows for single contract number, as I am begineer in ABAP, so need some help.

Regards,

Prashant.

0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

JL23
Active Contributor
0 Likes

you have problems with a loop and updating a Z-table (certainly not a MM problem)

how do you think we can help you without knowing your Z-program

Former Member
0 Likes

Dear,

Shall I send you the code for that

Regards,

Anup.

Former Member
0 Likes

Dear,

FORM SAVE_DATA.

            • Contract Number Generation -********************

SELECT * FROM NRIV INTO CORRESPONDING FIELDS OF TABLE IT_NRIV WHERE OBJECT = 'ZGREY'.

REFRESH IT_FINAL2.

READ TABLE IT_NRIV WITH KEY TOYEAR = C_YEAR.

IF SY-SUBRC = 0.

YEAR1 = IT_NRIV-TOYEAR.

ENDIF.

  • YR_R9 = SY-DATUM+4(2).

YR_R9 = C_YEAR+2(2).

IF CNTNO = '' AND CNTNO1 = '' AND CNTNO2 = '' .

  • IF CNTNO1 = ''.

CALL FUNCTION 'NUMBER_GET_NEXT'

EXPORTING

NR_RANGE_NR = '01'

OBJECT = 'ZGREY'

TOYEAR = YEAR1

IMPORTING

NUMBER = WDOCNO "Number generated by SAP

  • QUAN = QUAN

EXCEPTIONS

INTERVAL_NOT_FOUND = 1

NUMBER_RANGE_NOT_INTERN = 2

OBJECT_NOT_FOUND = 3

QUANTITY_IS_0 = 4

QUANTITY_IS_NOT_1 = 5

INTERNAL_OVERFLOW = 6

OTHERS = 7.

IF SY-SUBRC NE 0.

  • MESSAGE 'number range does not exist' TYPE 'I'.

  • message i013 with 'Number Range' sy-subrc.

ENDIF.

YEAR2 = YEAR1.

YR_R10 = YEAR2+2(2).

WDOC1 = WDOCNO.

CONCATENATE SEGM C_MNT YR_R10 WDOC1 NUMBER INTO NUMBER SEPARATED BY SPACE.

CNDT = SY-DATUM.

IF SY-SUBRC = 0.

CONDENSE NUMBER NO-GAPS.

CNTNO = NUMBER.

ENDIF.

CLEAR NUMBER.

              • System Timp Stamp....

  • C_TIME = SY-TIMLO.

MOVE SY-UZEIT TO C_TIME.

MOVE SY-UNAME TO C_USER.

***********************Copying All Screen Field Data To Z-Table********************************************

IT_FINAL-CNTNO = CNTNO. " contract number

IT_FINAL-CNDT = CNDT. " contract date

IT_FINAL-CC_CPUTM = C_TIME.

IT_FINAL-USNAM = C_USER.

IT_FINAL-YER = YER.

IT_FINAL-ORD_DATE = OC_DATE.

IT_FINAL-VTEXT1 = MTYPE.

IT_FINAL-OTP = OTP.

IT_FINAL-VTEXT = SEG.

IT_FINAL-CNAME = CNAME. " CNAME_R

IT_FINAL-C_NM = C_ATWRT.

IT_FINAL-MATNR = MAKT-MATNR. " Material no

IT_FINAL-MAKTX = MAKT-MAKTX. " Material Description

IT_FINAL-MRT = MRT.

IT_FINAL-WEV_TYP = WEV_TYP.

IT_FINAL-DES_TYP = DES_TYP.

IT_FINAL-SPART = SEGM.

APPEND IT_FINAL.

MODIFY ZWEV_CONTRA FROM IT_FINAL.

IF SY-SUBRC = 0.

MESSAGE 'Data Saved Successfully' TYPE 'I'.

ENDIF.

ENDIF.

JL23
Active Contributor
0 Likes

this is just the form that creates the new number and writes an entry to a Z-table.

this activity has to be splitted into taking the number from the range and writing to the Ztable.

while looping thru your source, you must somehow know what belongs together into one contract. within this condition you just have to pull a new number once from the range, but have to write a record to the z-table with for each item that belongs to this one contract.

jagadeesh_madiwalar
Active Contributor
0 Likes

HI

IT_FINAL-CNTNO = CNTNO. " contract number

IT_FINAL-CNDT = CNDT. " contract date

IT_FINAL-CC_CPUTM = C_TIME.

IT_FINAL-USNAM = C_USER.

IT_FINAL-YER = YER.

IT_FINAL-ORD_DATE = OC_DATE.

IT_FINAL-VTEXT1 = MTYPE.

IT_FINAL-OTP = OTP.

IT_FINAL-VTEXT = SEG.

IT_FINAL-CNAME = CNAME. " CNAME_R

IT_FINAL-C_NM = C_ATWRT.

IT_FINAL-MATNR = MAKT-MATNR. " Material no

IT_FINAL-MAKTX = MAKT-MAKTX. " Material Description

IT_FINAL-MRT = MRT.

IT_FINAL-WEV_TYP = WEV_TYP.

IT_FINAL-DES_TYP = DES_TYP.

IT_FINAL-SPART = SEGM.

Just check Contract item Number above, add that field and then check!!!!!!!!!!

Answers (1)

Answers (1)

jagadeesh_madiwalar
Active Contributor
0 Likes

Hi,

Hopefully you are not added the item Number in your Z-Table, Add the same and extract the contract which is having more then one line item.