‎2007 May 21 3:17 AM
Hi Friends,
I have a requriement like this first the user should accept a new record only if the status is CD. Next if the record is present in the table then it should proceeed for the next step that is the user should accept the next approval status DE and again continuous the same with other status like VE, AP, PV.
I got strucked in this coding can any one pls tell me how to code it
WHEN 'INSE'.
SELECT * FROM zinv_mov INTO corresponding fields of table lt_final
WHERE bukrs EQ zinv_mov-bukrs
AND lifnr EQ zinv_mov-lifnr
AND xblnr EQ zinv_mov-xblnr
AND appdate EQ zinv_mov-appdate.
IF sy-subrc <> 0.
PERFORM insert.
ELSE.
IF zinv_mov-usnam = 'CD'.
ELSE.
IF zinv_mov-usnam = 'DE'.
ELSE.
IF zinv_mov-usnam = 'VE'.
ELSE.
IF zinv_mov-usnam = 'AP'.
ELSE.
IF zinv_mov-usnam = 'PV'.
ELSE.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
Regards,
Line
‎2007 May 21 4:14 AM
hi
not sure i understood your query fully..but as far as i understand, you can do something like this...if for the first time itself, the status is ne CD, you can go out of the loop pass
select from ztable
loop at itab.
if itab-status Eq 'CD'.
select from ****
if sy-subrc eq 0.
if status eq 'DE'
do something
select from ****
if sy-subrc eq 0.
if status eq 'VE'.
do something.
else.
continue.
endif.
endif.
endif.
endif.
endloop
if helpful, reward
Sathish. R
‎2007 May 21 4:14 AM
hi
not sure i understood your query fully..but as far as i understand, you can do something like this...if for the first time itself, the status is ne CD, you can go out of the loop pass
select from ztable
loop at itab.
if itab-status Eq 'CD'.
select from ****
if sy-subrc eq 0.
if status eq 'DE'
do something
select from ****
if sy-subrc eq 0.
if status eq 'VE'.
do something.
else.
continue.
endif.
endif.
endif.
endif.
endloop
if helpful, reward
Sathish. R
‎2007 May 21 4:27 AM
Hi Line,
Can you please explain the query in more details if possible.
Regards,
Atish
‎2007 May 21 4:37 AM
WHEN 'INSE'.
SELECT * FROM zinv_mov INTO corresponding fields of table lt_final
WHERE bukrs EQ zinv_mov-bukrs
AND lifnr EQ zinv_mov-lifnr
AND xblnr EQ zinv_mov-xblnr
AND appdate EQ zinv_mov-appdate.
IF sy-subrc <> 0.
IF zinv_mov-usnam = 'CD'.
PERFORM insert.
ELSEIF zinv_mov-usnam = 'DE'.
ELSEIF zinv_mov-usnam = 'VE'.
ELSEIF zinv_mov-usnam = 'AP'.
ELSEIF zinv_mov-usnam = 'PV'.
ENDIF.
ENDIF.
Try with this . .....
Girish
‎2007 May 21 4:46 AM
Hi,
I have not fully understood ur requirement but what I understand is that First status 'CD' must be checked.Then 'DE', 'VE' etc.
Coding can be
WHEN 'INSE'.
SELECT * FROM zinv_mov INTO corresponding fields of table lt_final
WHERE bukrs EQ zinv_mov-bukrs
AND lifnr EQ zinv_mov-lifnr
AND xblnr EQ zinv_mov-xblnr
AND appdate EQ zinv_mov-appdate.
IF sy-subrc <> 0.
PERFORM insert.
ELSE.
CASE zinv_mov-usnam.
WHEN 'CD'.
WHEN 'DE'.
WHEN 'VE'.
WHEN 'AP'.
WHEN 'PV'.
ENDCASE.
ENDIF.
Regards,
Himanshu
‎2007 May 21 4:51 AM
i am not enough clear about your query but what i can understand i am explaining
WHEN 'INSE'.
SELECT * FROM zinv_mov INTO corresponding fields of table lt_final
WHERE bukrs EQ zinv_mov-bukrs
AND lifnr EQ zinv_mov-lifnr
AND xblnr EQ zinv_mov-xblnr
AND appdate EQ zinv_mov-appdate.
IF sy-subrc <> 0 and zinv_mov-usnam = 'CD'.
PERFORM insert.
ELSE.
IF zinv_mov-usnam = 'DE' .
ELSEIF zinv_mov-usnam = 'VE'.
ELSEIF zinv_mov-usnam = 'AP'.
ELSEIF zinv_mov-usnam = 'PV'.
ENDIF.
ENDIF.
here also i am confused that bukrs EQ zinv_mov-bukrs whether zinv_mov-bukrs
is an input field or table field if it is not an input field then it cant fetch the data..
regards
shiba dutta
‎2007 May 21 5:19 AM
Dear,
Sorry for my question.
Actually user wants to insert record in order wise when the status is like CD, DE, VE, AP, PV.
If it is a new record it should accept the status as CD(Coding), after that invoice is transfere to the other department where they will just key in the status like DE (Data Entry) and VE(Verification) for the next department so on.
But It should be in order. It cannot be jumped from one department to other.
Suppose it has been approved by 3 departments then the completed status is VE (verification) next status will be AP, but it should not accept PV.
It should pass from one department to other serial order as mentioned.
I need to code like that, Hope understood my querry.
Regards,
Line
‎2007 May 21 5:30 AM
Hi Line,
Can you please post your full piece of code?
Regards,
Atish
‎2007 May 21 6:18 AM
Hi,
************************************************************************
Description/Program Functions
*
************************************************************************
*
*This program get the details of the Invoice Movement into the database
*
*
************************************************************************
Responsibility
*
************************************************************************
*
*
Author .............: S.M.Parvez
*
Creation Date.......: 14.05.2007
*
Requested by........: Wendy
*
Owner ..............: SapuraCrest
*
Project.............:
*
*
Description.........: It gets the details of the invoices Movement
into the database.
*
*
*
************************************************************************
REPORT zpinv_mov .
TABLES : zinv_mov.
----
---- Types -
----
*TYPES FOR STORING Accounting: Secondary Index for Vendors
TYPES: BEGIN OF tw_final,
LIFNR type zinv_mov-lifnr,
XBLNR type zinv_mov-xblnr,
BUKRS type zinv_mov-bukrs,
PROCESE type zinv_mov-procese,
USNAM type zinv_mov-usnam,
APPDATE type zinv_mov-appdate,
STATUS type zinv_mov-status,
end of tw_final,
tt_final TYPE STANDARD TABLE OF tw_final.
************************************************************************
I N T E R N A L T A B L E S
************************************************************************
DATA: lw_final TYPE tw_final,
lt_final TYPE tt_final.
DATA: v_inv LIKE zinv_mov-xblnr,
ok_code LIKE sy-ucomm.
DATA : itab LIKE zinv_mov OCCURS 0 WITH HEADER LINE.
&----
*& Module USER_COMMAND_0102 INPUT
&----
text
----
MODULE user_command_0102 INPUT.
CASE: ok_code.
WHEN 'INSE'.
SELECT * FROM zinv_mov INTO corresponding fields of table lt_final
WHERE bukrs EQ zinv_mov-bukrs
AND lifnr EQ zinv_mov-lifnr
AND xblnr EQ zinv_mov-xblnr
AND appdate EQ zinv_mov-appdate.
IF sy-subrc <> 0.
PERFORM insert.
ELSE.
IF zinv_mov-usnam = 'CD'.
ELSE.
IF zinv_mov-usnam = 'DE'.
ELSE.
IF zinv_mov-usnam = 'VE'.
ELSE.
IF zinv_mov-usnam = 'AP'.
ELSE.
IF zinv_mov-usnam = 'PV'.
ELSE.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
**********
*select single xblnr from zinv_mov into v_inv
where bukrs EQ zinv_mov-bukrs
and lifnr EQ zinv_mov-lifnr
and usnam EQ zinv_mov-usnam
and appdate EQ zinv_mov-appdate.
**********
SELECT SINGLE xblnr FROM zinv_mov INTO v_inv
WHERE bukrs EQ zinv_mov-bukrs
AND lifnr EQ zinv_mov-lifnr
AND usnam EQ zinv_mov-usnam
AND appdate EQ zinv_mov-appdate.
IF sy-subrc = 0.
MESSAGE i000(x) WITH 'Invoice already processed by the user'.
ELSE.
*Generating the tranmittal number
SELECT MAX( trans )
INTO zinv_mov-trans FROM zinv_mov.
IF sy-subrc EQ 0.
zinv_mov-trans = zinv_mov-trans + '0000000001'.
ELSE.
MOVE '0000000001' TO zinv_mov-trans.
ENDIF.
MOVE zinv_mov TO itab.
APPEND itab.
INSERT INTO zinv_mov VALUES itab.
IF sy-subrc = 0.
MESSAGE i000(x) WITH 'Values inserted sucessfully'.
CLEAR zinv_mov.
ELSE.
MESSAGE i000(x) WITH 'Please check and re-enter correct values'.
ENDIF.
ENDIF.
ENDIF.
WHEN 'REFR'.
CALL TRANSACTION 'ZIINV'.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_0102 INPUT
&----
*& Module STATUS_0102 OUTPUT
&----
text
----
MODULE status_0102 OUTPUT.
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'TITLE_102'.
ENDMODULE. " STATUS_0102 OUTPUT
----
FORM insert *
----
........ *
----
FORM insert.
SELECT MAX( trans )
INTO zinv_mov-trans FROM zinv_mov.
IF sy-subrc EQ 0.
zinv_mov-trans = zinv_mov-trans + '0000000001'.
ELSE.
MOVE '0000000001' TO zinv_mov-trans.
ENDIF.
MOVE zinv_mov TO itab.
APPEND itab.
INSERT INTO zinv_mov VALUES itab.
IF sy-subrc = 0.
MESSAGE i000(x) WITH 'Values inserted sucessfully'.
CLEAR zinv_mov.
ELSE.
MESSAGE i000(x) WITH 'Please check and re-enter correct values'.
ENDIF.
ENDFORM.
regards,
Line