{"id":569,"date":"2013-05-14T13:23:42","date_gmt":"2013-05-14T12:23:42","guid":{"rendered":"http:\/\/oprsteny.cz\/?p=569"},"modified":"2013-11-20T21:22:49","modified_gmt":"2013-11-20T20:22:49","slug":"create-new-batch-characteristics-with-values-checked-and-suggested-by-a-function-module","status":"publish","type":"post","link":"https:\/\/oprsteny.cz\/?p=569","title":{"rendered":"Create new batch characteristics with values checked and suggested by a function module"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"358\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=358\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" data-orig-size=\"44,50\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Picasa&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1365690880&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"SAP\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" class=\"alignleft size-full wp-image-358\" alt=\"SAP\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" width=\"44\" height=\"50\" \/>In this example I&#8217;ll try to show you how to create new characteristics for a material batch. This will include the following steps:<\/p>\n<ol>\n<li>Creation of a function module to check characteristics value (optional)<\/li>\n<li>Creation of a function module to suggest characteristics value &#8211; search help (optional)<\/li>\n<li><span style=\"color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, 'Nimbus Sans L', sans-serif; font-style: normal;\">Creation of new characteristics (CT04)<\/span><\/li>\n<li><span style=\"color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, 'Nimbus Sans L', sans-serif; font-style: normal;\">Creation\/modification of a class (CL02)<\/span><\/li>\n<li><span style=\"color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, 'Nimbus Sans L', sans-serif; font-style: normal;\">Object\/Class assignment to a class (CL24N or CL20N and OMS2 if necessary)<\/span><\/li>\n<li>Batch modification with our new characteristics (MCS2N)<\/li>\n<\/ol>\n<p><!--more--><\/p>\n<h1>1.\u00a0Creation of a function module to check characteristics value<\/h1>\n<p>In the following code you can see very basic check which can of course be much more complex for your specific scenario.<\/p>\n<pre lang=\"abap\">FUNCTION Z_CHECK_050.\r\n*\"----------------------------------------------------------------------\r\n*\"*\"Local Interface:\r\n*\"  IMPORTING\r\n*\"     REFERENCE(CHARACT_NO) TYPE  CABN-ATINN\r\n*\"     REFERENCE(CHARACT) TYPE  CABN-ATNAM\r\n*\"     REFERENCE(VALUE) TYPE  CAWN-ATWRT\r\n*\"  EXCEPTIONS\r\n*\"      NOT_FOUND\r\n*\"----------------------------------------------------------------------\r\n\r\n\" Allow empty value\r\n  check value is NOT INITIAL.\r\n\r\n\" Just for demonstration purposes we check for fixed values\r\n  if value &lt;&gt; 1 and \r\n     value &lt;&gt; 2 and\r\n     value &lt;&gt; 3.\r\n    RAISE NOT_FOUND.\r\n  endif.\r\nENDFUNCTION.<\/pre>\n<h1>2. Creation of a function module to suggest characteristics value<\/h1>\n<p>In the following code I&#8217;ll create my own field catalog for selection grid to be displayed. We will need a checkbox column (called CHK) which will inform about which values (multiple allowed) are selected<\/p>\n<pre lang=\"abap\">FUNCTION z_check_050_f4.\r\n*\"----------------------------------------------------------------------\r\n*\"*\"Local Interface:\r\n*\"  IMPORTING\r\n*\"     REFERENCE(CHARACT_NO) TYPE  CABN-ATINN\r\n*\"     REFERENCE(CHARACT) TYPE  CABN-ATNAM\r\n*\"     REFERENCE(DISPLAY)\r\n*\"     REFERENCE(ADDITIONAL_VALUES) TYPE  CABN-ATSON\r\n*\"     REFERENCE(MULTIPLE_VALUES) TYPE  RCTMV-ATLIS\r\n*\"     REFERENCE(LANGUAGE) TYPE  SY-LANGU\r\n*\"     REFERENCE(DISPLAY_WITH_LANGUAGE)\r\n*\"  TABLES\r\n*\"      VALUES STRUCTURE  RCTVALUES\r\n*\"----------------------------------------------------------------------\r\n  TYPE-POOLS : slis.\r\n\r\n  CONSTANTS:\r\n      c_werks(50) TYPE c VALUE '(SAPLCHRG)DFBATCH-WERKS'.\r\n\r\n  types:\r\n    BEGIN OF ty_data,\r\n      chk(1) type c,\r\n      value type c,      \r\n    END OF ty_data.\r\n\r\n  DATA:\r\n    lt_values type TABLE OF ty_data,\r\n    l_werks TYPE  dfbatch-werks,\r\n    lt_fieldcat TYPE slis_t_fieldcat_alv.\r\n\r\n  FIELD-SYMBOLS:\r\n    &lt;fs_value&gt; type ty_data,\r\n    &lt;fs_werks&gt;,\r\n    &lt;fs_rctvalue&gt; TYPE rctvalues,\r\n    &lt;fs_fcat&gt; type slis_fieldcat_alv.\r\n\r\n  ASSIGN (c_werks) TO &lt;fs_werks&gt;.\r\n  IF sy-subrc EQ 0.\r\n    l_werks  = &lt;fs_werks&gt;.\r\n  ENDIF.\r\n\r\n  CHECK l_werks IS NOT INITIAL.\r\n\r\n  APPEND INITIAL LINE TO lt_values ASSIGNING &lt;fs_value&gt;.\r\n  &lt;fs_value&gt;-value = '1'.\r\n  APPEND INITIAL LINE TO lt_values ASSIGNING &lt;fs_value&gt;.\r\n  &lt;fs_value&gt;-value = '2'.\r\n  APPEND INITIAL LINE TO lt_values ASSIGNING &lt;fs_value&gt;.\r\n  &lt;fs_value&gt;-value = '3'.      \r\n\r\n  APPEND INITIAL LINE TO lt_fieldcat ASSIGNING &lt;fs_fcat&gt;.\r\n  &lt;fs_fcat&gt;-fieldname  = 'CHK'.\r\n  &lt;fs_fcat&gt;-seltext_m  = ''.\r\n  &lt;fs_fcat&gt;-ddictxt(1) = 'M'.\r\n\r\n  APPEND INITIAL LINE TO lt_fieldcat ASSIGNING &lt;fs_fcat&gt;.\r\n  &lt;fs_fcat&gt;-fieldname  = 'VALUE'.\r\n  &lt;fs_fcat&gt;-seltext_m  = 'Value'.\r\n  &lt;fs_fcat&gt;-outputlen  = 10.\r\n  &lt;fs_fcat&gt;-ddictxt(1) = 'M'.\r\n\r\n  loop at lt_values ASSIGNING &lt;fs_value&gt;.\r\n    READ TABLE values with KEY value = &lt;fs_value&gt;-value TRANSPORTING NO FIELDS.\r\n    if sy-subrc = 0.\r\n      &lt;fs_value&gt;-chk = 'X'.\r\n    ENDIF.\r\n  ENDLOOP.\r\n\r\n  CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'\r\n    EXPORTING\r\n      i_title       = 'Allowed values'\r\n      i_selection   = 'X'\r\n      i_zebra       = 'X'\r\n      i_checkbox_fieldname = 'CHK'\r\n      i_tabname     = 'LT_VALUES'\r\n      it_fieldcat   = lt_fieldcat\r\n    TABLES\r\n      t_outtab      = lt_values\r\n    EXCEPTIONS\r\n      program_error = 1\r\n      OTHERS        = 2.\r\n\r\n  LOOP AT lt_values ASSIGNING &lt;fs_value&gt; where chk = 'X'.\r\n    READ TABLE values with KEY value = &lt;fs_value&gt;-value TRANSPORTING NO FIELDS.\r\n    if sy-subrc = 0.\r\n*     selected value had already been assigned - no action needed\r\n    else.\r\n*     new value selected -&gt; add it to the list\r\n      APPEND INITIAL LINE TO values ASSIGNING &lt;fs_rctvalue&gt;.\r\n      &lt;fs_rctvalue&gt;-value = &lt;fs_value&gt;-value.\r\n      &lt;fs_rctvalue&gt;-status = 'I'.\r\n    ENDIF.\r\n  endloop.\r\n\r\n  LOOP AT values ASSIGNING &lt;fs_rctvalue&gt; where status &lt;&gt; 'I'.\r\n    READ TABLE lt_values with KEY\r\n      value = &lt;fs_rctvalue&gt;-value\r\n      chk      = 'X'\r\n      TRANSPORTING NO FIELDS.\r\n    if sy-subrc &lt;&gt; 0.\r\n*     value was de-selected - we have to delete it\r\n      &lt;fs_rctvalue&gt;-status = 'D'.\r\n    endif.\r\n  ENDLOOP.\r\n\r\nENDFUNCTION.<\/pre>\n<h1>3. Creation of new characteristics<\/h1>\n<p>Run Transaction CT04, enter name of new batch and press\u00a0<em>CREATE<\/em> icon<a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/img_5192171c03f61.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft\" title=\"New characteristics\" alt=\"\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/img_5192171c03f61.png\" width=\"637\" height=\"213\" \/><\/a><\/p>\n<p>Enter description of the characteristics, set Status to Released, in Format section select your desired format (we&#8217;ll create multiple values, character type of length 15)<a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/img_519226bb0bb07.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full alignleft\" title=\"New characteristics - details\" alt=\"\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/img_519226bb0bb07.png\" width=\"556\" height=\"423\" \/><\/a><\/p>\n<p>Now we need to assign our check function module to the characteristics &#8211; Go to tab\u00a0<em>Values<\/em>, click on\u00a0<em>Other Value Check <\/em>and select radio with label\u00a0<em>Funct. module<\/em><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/img_519218ed97e66.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full alignleft\" title=\"Assigning FM to check values\" alt=\"\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/img_519218ed97e66.png\" width=\"569\" height=\"227\" \/><\/a><\/p>\n<p>When prompted, enter name of our check FM &#8211; <em>Z_CHECK_050<\/em>.<a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/img_519221c4ef767.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full alignleft\" title=\"Enter FM name\" alt=\"\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/img_519221c4ef767.png\" width=\"575\" height=\"135\" \/><\/a><\/p>\n<p><em>Note:<\/em> The search help function module <em>Z_CHECK_050_F4<\/em> is assigned automatically<\/p>\n<h1>4. Creation\/modification of a class<\/h1>\n<p>Run TCode CL02 and create new or edit existing class for class type 022 (Batch).\u00a0Enter some description (for new class), go to tab <em>Char. <\/em>and assign our new characteristics ZBM_0050 to class.<\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/img_51922455969e3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full\" title=\"Assignment of characteristics to a class\" alt=\"\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/img_51922455969e3.png\" width=\"510\" height=\"244\" \/><\/a><\/p>\n<h1>5.\u00a0Object\/Class assignment to a class<\/h1>\n<p>Run TCode CL24N select Class B0001, class type 022<\/p>\n<ul>\n<li>for new class without existing assignments click on button <em>Only new assignments<\/em>\u00a0and select <em>Material<br \/>\n<a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/img_5192234c72788.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" title=\"New class\/object assignment to Class\" alt=\"\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/img_5192234c72788.png\" width=\"591\" height=\"424\" \/><\/a><br \/>\n<\/em><\/li>\n<li>for class with existing assignments just\u00a0press enter <a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/img_519225418474f.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full alignnone\" title=\"Class\/Object assignment to Class\" alt=\"\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/img_519225418474f.png\" width=\"597\" height=\"583\" \/><\/a><\/li>\n<\/ul>\n<p><em>Note:<\/em> In case you get message like\u00a0&#8220;Article type XXYY \u00a0does not support classification&#8221;, use TCode OMS2 and make sure material type XXYY has &#8220;Classification&#8221; option selected in box &#8220;User departments&#8221;.<\/p>\n<h2>6.\u00a0Batch modification with our new characteristics<\/h2>\n<p>Run TCode MSC2N and change a batch for given material. You can see that\u00a0our new characteristics is available<a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/img_5192260a50569.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full alignleft\" title=\"New characteristics is available for batch\" alt=\"\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/img_5192260a50569.png\" width=\"611\" height=\"480\" \/><\/a><\/p>\n<p>Try to enter some value different from 1,2 or 3 (values defined in our check FM) and press enter<br \/>\n<a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/img_5192264c43d71.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full alignnone\" title=\"Manually typed wrong characteristics value\" alt=\"\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/img_5192264c43d71.png\" width=\"450\" height=\"124\" \/><\/a><\/p>\n<p>Press F4 and select some value<br \/>\n<a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/img_519226733969c.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full alignnone\" title=\"Select multiple characteristics\" alt=\"\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/img_519226733969c.png\" width=\"256\" height=\"211\" \/><\/a><br \/>\n<a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/img_519227f65ccd7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full alignleft\" title=\"Selected characteristics are displayed\" alt=\"\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/img_519227f65ccd7.png\" width=\"535\" height=\"272\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Press F4 again and check that your previously selected values are already checked.<a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/img_51922838bfa55.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full alignnone\" title=\"Previously selected values are checked\" alt=\"\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/img_51922838bfa55.png\" width=\"254\" height=\"210\" \/><\/a><\/p>\n<p>Now you can just save your batch &#8211; we are DONE \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this example I&#8217;ll try to show you how to create new characteristics for a material batch. This will include the following steps: Creation of a function module to check characteristics value (optional) Creation of a function module to suggest &hellip; <a href=\"https:\/\/oprsteny.cz\/?p=569\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"SAP ABAP: Create new batch characteristics with values checked and suggested by a FM","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[16,9],"tags":[446,147,145,144,139,141,142,146,140,143,17],"class_list":["post-569","post","type-post","status-publish","format-standard","hentry","category-abap","category-development","tag-abap","tag-assignment","tag-batch","tag-characteristics","tag-cl02","tag-cl20n","tag-cl24n","tag-class","tag-ct04","tag-msc2n","tag-sap"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3nYbe-9b","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/569","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=569"}],"version-history":[{"count":6,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/569\/revisions"}],"predecessor-version":[{"id":866,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/569\/revisions\/866"}],"wp:attachment":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=569"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=569"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=569"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}