Hi All,
I am trying to update ANLA-INVNR from Transaction MIGO. I have added a field to MIGO and I have to update the value of the field to INVNR field of ANLA. The problem is when I am debugging it, it updates the value of INVNR in the table but as soon as I execute it and the document number is generated, the value of field INVNR again changes to initial i.e. Zero. Could someone explain to me the possibilities why it is again changing it to initial value.
Thanks & Regards,
Chandni Sharma.
HI Chandni,
i am not sure if i have understood your problem statement.
Could you update the table or not? Is it being initialized after the update?
Regards,
Xineohpi.
Hi Xineohpi,
Thanks for your reply and the field is getting updated in the table ANLA and as soon as i execute it further it changes the value of the field back to initial in the table ANLA.
Thanks & Regards,
Chandni Sharma.
Hi Chandni,
Pl. write your code here.
Hi vivek,
The code i used is placed in a function module and the code is as follows:
IF SY-TCODE = 'MIGO'.
TABLES: ANLA.
DATA: NAMETAB TYPE TABLE OF DFIES,
FIELDDIF TYPE TABLE OF FIELD_DIF,
WA_FIELDDIF LIKE LINE OF FIELDDIF.
DATA: BEGIN OF TAB OCCURS 0,
ANLN1 TYPE ANLA-ANLN1,
ZZTAGNUM TYPE BSEG-ZZTAGNUM,
END OF TAB.
DATA: T_ANLA TYPE TABLE OF ANLA.
DATA: WA_TAB LIKE LINE OF TAB,
WA_BSEG LIKE LINE OF T_BSEG,
WA_ANLA LIKE LINE OF T_ANLA.
DATA: I(3).
*-------------------Placing Values of Field Asset Number---------------------------------------------*
LOOP AT T_BSEG INTO WA_BSEG.
CHECK WA_BSEG-ANLN1 IS NOT INITIAL.
WA_TAB-ANLN1 = WA_BSEG-ANLN1.
APPEND WA_TAB TO TAB.
CLEAR WA_TAB.
CLEAR WA_BSEG.
ENDLOOP.
*-------------------Non-Editable Field of Table Control---------------------------------------------*
WA_FIELDDIF-TABNAME = 'ZBSEG'.
WA_FIELDDIF-FIELDNAME = 'ANLN1'.
WA_FIELDDIF-NO_INPUT = 'X'.
WA_FIELDDIF-TBPOSITION = '01'.
APPEND WA_FIELDDIF TO FIELDDIF.
*-------------------Editable Field of Table Control---------------------------------------------*
WA_FIELDDIF-TABNAME = 'ZBSEG'.
WA_FIELDDIF-FIELDNAME = 'ZZTAGNUM'.
WA_FIELDDIF-NO_INPUT = ' '.
WA_FIELDDIF-TBPOSITION = '02'.
APPEND WA_FIELDDIF TO FIELDDIF.
*------------------------------Popup For Table Control------------------------------------------*
CALL FUNCTION 'STC1_POPUP_WITH_TABLE_CONTROL'
EXPORTING
HEADER = 'Please Enter A Tag Number'
TABNAME = 'ZBSEG'
* DISPLAY_ONLY =
* ENDLESS =
* DISPLAY_TOGGLE =
* SORT_FORBIDDEN =
* MODIFY_CHECK =
* INSERT_CHECK =
* DELETE_CHECK =
* MODIFY_DISP_FIELD =
* NO_INSERT =
* NO_DELETE =
* NO_MOVE =
* NO_UNDO =
NO_BUTTON = 'X'
* X_START = 5
* Y_START = 5
* X_END = 80
* Y_END = 25
TABLES
* NAMETAB = NAMETAB
TABLE = TAB
FIELDDIF = FIELDDIF
* EXCEPTIONS
* NO_MORE_TABLES = 1
* TOO_MANY_FIELDS = 2
* NAMETAB_NOT_VALID = 3
* HANDLE_NOT_VALID = 4
* OTHERS = 5
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*-----------------------Updating Entered Values of ZZTAGNUM To ANLA---------------------------------*
LOOP AT TAB INTO WA_TAB.
IF WA_TAB-ZZTAGNUM IS INITIAL.
MESSAGE 'PLEASE ENTER TAG NUMBER' TYPE 'E'.
ELSE.
CHECK WA_TAB-ANLN1 IS NOT INITIAL.
WA_ANLA-INVNR = WA_TAB-ZZTAGNUM.
WA_ANLA-ANLN1 = WA_TAB-ANLN1.
UPDATE ANLA SET INVNR = WA_ANLA-INVNR WHERE ANLN1 = WA_ANLA-ANLN1.
CLEAR WA_TAB.
CLEAR WA_ANLA.
ENDIF.
ENDLOOP.
ENDIF.
Y don't you try filling the internal tale T_ANLA first and then
UPDATE anla FROM TABLE t_anla.
I believe you will get BUKRS, ANLN2 as well from BSEG.
Dear Chandini ,
First Why you are directly updating Standard table , it is not recomended ,
Either go with STANDARD BAPI if still you want to update ... then where is Commit WORK ?
You there is success full transaction then there will be auto Transaction Commit but if it is not then it will be rolled back . so you commit work .
regards
Deepak.
Hi Deepak,
Thanks for you reply, please could you elaborate on where should i place commit work. I tried putting it after the endloop but it doesn't seems to work.
Thanks & Regards,
Chandni Sharma.
Use it just after your Update Statement.
Use this statement.
if sy-subrc = 0.
commit work.
else.
rollback work.
endif.
hi ,
WHile debugging you just check what is the status of Sy-subrc after Update statement
and also check the where condition which you are using are values in correct format which is required i.e primary key values .
after each update you can use commit work
for your reference just query from se16 on table anla for selection criteria of where condition whter really entry to be updated exist or not .
Go STEP BY STEP .
regards
Deepak.
Thanks for your reply, but my update statement is working till i am inside the loop. i can check the values in table ANLA. I tried placing commit work after update statement. still it is working fine and i can check the values till i am inside the function module but as soon as i proceed from the FM the values in the table ANLA field INVNR are getting initialized. had the problem been with the UPDATE statement it would be relevant to make changes to it but it is working fine inside the FM. and i also checked sy-subrc it is 0 only.
Hi,
Just check the value of field ANLN1 in table TAB. Check whether you are getting value or not. If you are getting any value then use commit after update. Just try it once.
LOOP AT TAB INTO WA_TAB.
IF WA_TAB-ZZTAGNUM IS INITIAL.
MESSAGE 'PLEASE ENTER TAG NUMBER' TYPE 'E'.
ELSE.
CHECK WA_TAB-ANLN1 IS NOT INITIAL.
WA_ANLA-INVNR = WA_TAB-ZZTAGNUM.
WA_ANLA-ANLN1 = WA_TAB-ANLN1.
UPDATE ANLA SET INVNR = WA_ANLA-INVNR WHERE ANLN1 = WA_ANLA-ANLN1.
CLEAR WA_TAB.
CLEAR WA_ANLA.
ENDIF.
ENDLOOP.
I am getting the values of asset number and the table also is showing the values until i am in the loop. but as soon as the loop is completed the values are again changing to initial. i tried using commit work exactly after the update statement and i tried using commit work after the endloop still as soon as i proceed the values are again changing to 0. please elaborate on where i should commit work to be able to retain the values in table.
hi ,
I think you should look for BAPI : BAPI_FIXEDASSET_CHANGE
read info about this BAPI and use it .
regards
Deepak.
ALso check this NOTE : related to above BAPI :
note : 1176061
I was debugging this program and found out, it is retaining the value till enhancement point- document operation-05. and after this the value is getting initialized.
But I am not able to understand what is changing it to the initial value since when i tried to put break-point in it, it displayed the error the enhancement is not active so you cannot put a break-point.
you can find the enhancement point in the Function Group MIGO --> include LMIGOKD1 --> line no 1170.
Thanks & Regards,
Chandni Sharma.