Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Showing posts with label Application Related. Show all posts
Showing posts with label Application Related. Show all posts

Saturday, April 26, 2008

General - Number Range Generation ABAP Interview Questions

General - Number Range Generation


* In the 4.6x environment, SAP have included a number range generation
* program just like those used for Purchase Order, Sales Order etc.
*
* This SAP number range generation is an include program.
*
* INCLUDE ZRANGENO.
*
* Always have to be included in the main program data declaration
*
* data: wnorange like INRI-NRRANGENR, "number range,
* wsubobj like inri-SUBOBJECT, "sub object
* wdocno(12).
*
* Steps :-
* 1. Number range Sub Object must be maintain in table ZSGRP
* You can used transaction SE16 to create a table entries.
* 2. Maintain number range and intervals in transaction code SNUM
*
* Written by : SAP Basis, ABAP Programming and Other IMG Stuff
*
*

call function 'NUMBER_RANGE_ENQUEUE'
exporting
object = 'ZOWNNO' "Create with SNUM
exceptions
foreign_lock = 1
object_not_found = 2
system_failure = 3
others = 4.
if sy-subrc ne 0.
* message e086 with 'Lock error' sy-subrc.
endif.

call function 'NUMBER_GET_NEXT'
exporting
nr_range_nr = wnorange
object = 'ZOWNNO'
subobject = wsubobj
importing
number = wdocno "Number generated by SAP
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 e086 with 'Number Range' sy-subrc.
endif.

call function 'NUMBER_RANGE_DEQUEUE'
exporting
object = 'ZOWNNO'.

if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.

Extract the smtp email address ABAP Interview Questions



*
* Extract the smtp email address from the User Profile SU01 or
* Vendor Master LFA1
*
* Written by : SAP Basis, ABAP Programming and Other IMG Stuff
*
*
REPORT ZSMTPADR.

TABLES: USR21,
LFA1,
ADR6.

DATA: BEGIN OF WA,
BNAME TYPE USR21-BNAME,
LIFNR TYPE LFA1-LIFNR,
ADRNR TYPE LFA1-ADRNR,
PERSNUMBER TYPE ADR6-PERSNUMBER,
ADDRNUMBER TYPE ADR6-ADDRNUMBER,
SMTP_ADDR TYPE ADR6-SMTP_ADDR,
END OF WA,
ITAB LIKE SORTED TABLE OF WA
WITH NON-UNIQUE KEY BNAME LIFNR.

SELECT-OPTIONS: UNAME FOR USR21-BNAME.
SELECT-OPTIONS: LIFNR FOR LFA1-LIFNR.

IF UNAME-LOW <> SPACE.
SELECT U~BNAME U~PERSNUMBER U~ADDRNUMBER
A~SMTP_ADDR
INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM ( USR21 AS U
INNER JOIN ADR6 AS A ON A~PERSNUMBER = U~PERSNUMBER
AND A~ADDRNUMBER = U~ADDRNUMBER )
WHERE U~BNAME IN UNAME.

LOOP AT ITAB INTO WA.
WRITE:/ WA-BNAME, WA-SMTP_ADDR(50).
ENDLOOP.
ENDIF.


IF LIFNR-LOW <> SPACE.
SELECT L~LIFNR L~ADRNR
A~SMTP_ADDR
INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM ( LFA1 AS L
INNER JOIN ADR6 AS A ON A~ADDRNUMBER = L~ADRNR )
WHERE L~LIFNR IN LIFNR.

LOOP AT ITAB INTO WA.
WRITE:/ WA-LIFNR, WA-SMTP_ADDR(50).
ENDLOOP.
ENDIF.
*-- End of Program

How to Get the Version Value When I Print the PO ABAP Interview Questions

Need to display the Version of PO in the printout. But the table ekko or erev doesn't contain the version value at runtime.


The following example code will get the version no. in PO :-

referesh : erevitem.
clear : erevlines.

SELECT SINGLE * FROM cdpos
WHERE objectid = ebeln AND
value_old = 'G' AND
value_new = 'B'.

IF sy-subrc EQ 0.

erevlines = erevlines + 1.

ELSE.

erevlines = 0.

ENDIF.

SELECT * FROM nast
INTO CORRESPONDING FIELDS OF TABLE itab_nast
WHERE objky = ebeln AND
vstat NE '0'.

CLEAR itab_nast.
SORT itab_nast DESCENDING BY erdat eruhr.

READ TABLE itab_nast INDEX 1.

IF sy-subrc EQ 0.
IF itab_nast-vstat NE '0'.

LOOP AT l_doc-xekpo INTO tekpo.

CALL FUNCTION 'ME_CHANGEDOC_SELECT'
EXPORTING
i_document_category = pekko-bstyp
i_document_number = ebeln
i_document_item = tekpo-ebelp
* I_DATE_START =
* I_TIME_START =
* I_DATE_END =
* I_TIME_END =
* I_USERNAME =
* I_ALL_ITEMS =
* I_GRIDHANDLE =
* I_REVISIONLIST =
* I_ARCHIVE_HANDLE =
IMPORTING
* E_LINES =
e_outtab = imecdgrid.


it_mecdgrid[] = imecdgrid[].

LOOP AT it_mecdgrid INTO wa_mecdgrid WHERE tabkey+13(5) = tekpo-ebelp.


IF wa_mecdgrid-fname = 'MENGE'.

itab_po_change-matnr = tekpo-matnr.
itab_po_change-text = '***** Quantity Change ******'.
erevlines = erevlines + 1.


APPEND itab_po_change.

ENDIF.

IF wa_mecdgrid-fname = 'NETWR'.

itab_po_change-matnr = tekpo-matnr.
itab_po_change-text = '***** Price Change ******'.
erevlines = erevlines + 1.


APPEND itab_po_change.


ENDIF.


ENDLOOP.


ENDLOOP.

SORT itab_po_change BY matnr text.

LOOP AT itab_po_change.

DELETE ADJACENT DUPLICATES FROM itab_po_change COMPARING matnr text.

ENDLOOP.


ENDIF.
ENDIF.


SELECT * FROM erev INTO CORRESPONDING FIELDS OF TABLE erev WHERE edokn = pekko-ebeln.

SORT erev BY revno DESCENDING.



LOOP AT erev.
MOVE-CORRESPONDING erev TO erevitem.
APPEND erevitem.
ENDLOOP.

DESCRIBE TABLE erevitem LINES erevlines.
IF erevlines = 1.
CLEAR erevitem[].
erevlines = 0.
ENDIF.
*
** erevlines = erevlines - 1.
*
DELETE erevitem WHERE revno = 0.
CLEAR erevlines.
DESCRIBE TABLE erevitem LINES erevlines.

call function fm_name
exporting
erevlines = erevlines

tables
erev = erevitem
endform.


IN SSF :

loop at erev into wa_erev where erevlines > '0'.


wa_erevlines-revno(.0) for version no.
wa_erevlines-txz01 for version text

Recent Topics